View Full Version : Totally dynamic embedded SQL
09-14-2005, 04:28 AM
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/infocenter/iSeries/v5r3/ic2924/index.htm Then select database, reference, SQL reference, and SQLDA. I'll try to put together an example, unless someone beats me to it.
09-14-2005, 09:49 PM
John, I would store the SQL statements in a SRCPF and use the mebername as the SQL statement name. SQLDA is indeed the answer. You can look at DYNSQL (http://firstname.lastname@example.orgVMfHb6dae.1@.214a2d75/0) by David Morris Regards, Carel Teijgeler
09-18-2005, 11:44 PM
Hi, As both of you suggests SQLDA I will try to see if I'm capable of finding out how exactly this technology is used. kforsythe, if you have an example, I would really appreciate it ;-) Thank you in advance! Best regards, John
03-09-2006, 04:59 AM
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
03-09-2006, 04:59 AM
I was wondering if this is scenario is possible from within SQLRPGLE using embedded SQL:</p> SQL STATEMENT STORAGE:</p> 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:</p> SELECT field1, field2 FROM library1.table1 SELECT * FROM library2.table2 SELECT * FROM <a join between multiple SELECTs></p> From the above statements you can see that the field names, number of fields, etc. can be dynamic.</p> 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.</p> Does anyone have a solution to this? Maybe a link to an example, a source example, some ideas to try out or anything else?</p> Thanks in advance!</p>
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.