The prepared statement must be "Described" into a data structure from IBM called the SQLDA. As each row is fetched you can use the information in that data structure to retrieve each column of data. I would suggest taking each column and merging them into one string, then move that into a data structure passed from the caller. Take this link to the information center http://publib.boulder.ibm.com/infoce...2924/index.htm Then select database, reference, SQL reference, and SQLDA. I'll try to put together an example, unless someone beats me to it.
Unconfigured Ad Widget
Collapse
Announcement
Collapse
No announcement yet.
Totally dynamic embedded SQL
Collapse
X
-
Totally dynamic embedded SQL
I was wondering if this is scenario is possible from within SQLRPGLE using embedded SQL: SQL STATEMENT STORAGE: A data area, file or something else (actually this doesn't matter!) that holds a SQL statement that I do not know the syntax of. It is created by another program and is totally dynamic. Fx. it could be like any of the following: SELECT field1, field2 FROM library1.table1 SELECT * FROM library2.table2 SELECT * FROM From the above statements you can see that the field names, number of fields, etc. can be dynamic. THE ILERPG PROGRAM: This program should read the dynamic SQL statement into a string and execute it using embedded SQL... maybe a prepared statement? How the program will read the SQL statement into a string is not relevant; I know how to do this but it is mentioned so that you can see that I want to be able not have the SQL hardcoded into the RPG program ;o) It should be possible to have some kind of array or data structure that holds the content of the record returned and if possible also the structure of the fields within the record (if it is an INT, a VARCHAR, the length, decimal positions etc.). No hard-coded data structures, external datastructures or likewise is possible as the SQL statement is dynamic. Does anyone have a solution to this? Maybe a link to an example, a source example, some ideas to try out or anything else? Thanks in advance!
Comment
-
Totally dynamic embedded SQL
go to www.rpgbeans.com and use this great technique. Joel cochran explain how to encapsulate file access with dynamics sql into a service program whitout hardcode your programs. I start to use this tech' on my programs last summer, and you don't know how is simple and flexible to use... now this is the technique i prefer... bye
Comment
Comment