Is this even possible? I've been reading a ton of articles explaining how DB2 interacts with host structures.. I'm just not finding what I need. I'm pretty sure I'm defining my host structures the wrong way....
I have an as400 PF file with over 100 fields. I'm being typical programmer.. trying to skip steps. 100+ evals is pretty lame... no?
I know I can define a ds-array like this.... this is a simple example of what I'm trying.
dcl-ds ray qualified Dim(10);
Fld1 char(10);
Fld2 char(10);
End-ds
I can use SQL to select values directly into this ds-array...
/Free
Exec sql
Declare Curse cursor for
Select 'Cool' as Fld1,
'Guy' as Fld2
From Examp/Table
Limit 1;
Exec sql
Open Curse;
Exec Sql
Fetch Curse
For 1 rows
into :ray;
Exec sql
Close Curse;
Now that ds-array index(1) has those two values.
If ray.Fld1(1) <> *blanks;
Exec Sql
Create Table Test/Tester
( @fld1 char(10),
@fld2 char(10));
Endif;
How in the heck do I use this ds-array with an INSERT statement? I've tried several things...
Exec sql
insert into Test/Tester
(@fld1, @fld2)
Values( :ray.Fld1(1),
:ray.Fld2(1)) <---- DOESNT WORK!!
for 1 rows;
Exec sql
insert into Test/Tester <----- DOESNT WORK!
Values ( ray);
EXEC SQL
insert into Test/Tester <------ Doesnt Work!
Values( :ray(1));
/End-Free
How can I get this done? This is a simple example... the code I'm workin on involves a file with 100+ fields.
My goal is to avoid 100 lines of.... Thing1 = fileThing1.... Thing2 = FileThing2.... Etc... Write File....
I'm reading everything I can about DB2 and Host Structures.... I know the declaration is very ticky...
Do I need some type of overlay:next keyword?? If the host structure works with the fetch statement... shouldnt I be able to use it with the insert statement?
Pls push me in ANY direction!!!
Thanks
I have an as400 PF file with over 100 fields. I'm being typical programmer.. trying to skip steps. 100+ evals is pretty lame... no?
I know I can define a ds-array like this.... this is a simple example of what I'm trying.
dcl-ds ray qualified Dim(10);
Fld1 char(10);
Fld2 char(10);
End-ds
I can use SQL to select values directly into this ds-array...
/Free
Exec sql
Declare Curse cursor for
Select 'Cool' as Fld1,
'Guy' as Fld2
From Examp/Table
Limit 1;
Exec sql
Open Curse;
Exec Sql
Fetch Curse
For 1 rows
into :ray;
Exec sql
Close Curse;
Now that ds-array index(1) has those two values.
If ray.Fld1(1) <> *blanks;
Exec Sql
Create Table Test/Tester
( @fld1 char(10),
@fld2 char(10));
Endif;
How in the heck do I use this ds-array with an INSERT statement? I've tried several things...
Exec sql
insert into Test/Tester
(@fld1, @fld2)
Values( :ray.Fld1(1),
:ray.Fld2(1)) <---- DOESNT WORK!!
for 1 rows;
Exec sql
insert into Test/Tester <----- DOESNT WORK!
Values ( ray);
EXEC SQL
insert into Test/Tester <------ Doesnt Work!
Values( :ray(1));
/End-Free
How can I get this done? This is a simple example... the code I'm workin on involves a file with 100+ fields.
My goal is to avoid 100 lines of.... Thing1 = fileThing1.... Thing2 = FileThing2.... Etc... Write File....
I'm reading everything I can about DB2 and Host Structures.... I know the declaration is very ticky...
Do I need some type of overlay:next keyword?? If the host structure works with the fetch statement... shouldnt I be able to use it with the insert statement?
Pls push me in ANY direction!!!
Thanks
Comment