I am writing a dynamic SQL query to select 4 fields from a database. Hence, I have coded my DS/subfield definitions as:
D DSNAME DS
D Field1 10
D Field2 10
D Field3 10
D Field4 10
And my DECLARE/FETCH cursor statement goes like:
Declare C0 cursor for select field1, field2, field3, field4 from table
Fetch C0 into : DSNAME
At the end of execution, I have the 4 fields selected properly from my table to the defined data structure (which is as expected).
However, my requirement now is to select 100 fields from table (I do not want to perform SELECT * FROM TABLE, rather I will be doing SELECT FIELD1, FIELD2, ......, FIELD100 FROM TABLE).
As you can see, the complication is it would not be feasible to define 100 subfields in the DS.
Can anyone tell me how the DS should be coded in this scenario? I tried DIM statement, however in vain.
D DSNAME DS
D Field1 10
D Field2 10
D Field3 10
D Field4 10
And my DECLARE/FETCH cursor statement goes like:
Declare C0 cursor for select field1, field2, field3, field4 from table
Fetch C0 into : DSNAME
At the end of execution, I have the 4 fields selected properly from my table to the defined data structure (which is as expected).
However, my requirement now is to select 100 fields from table (I do not want to perform SELECT * FROM TABLE, rather I will be doing SELECT FIELD1, FIELD2, ......, FIELD100 FROM TABLE).
As you can see, the complication is it would not be feasible to define 100 subfields in the DS.
Can anyone tell me how the DS should be coded in this scenario? I tried DIM statement, however in vain.
Comment