|
Hi Carel, <snip>The QSQPRCED API uses the SQLDA descriptor. The SQLDA data structure contains an array, which you have to lopp through to get the column data retrieved.
You can also use embedded SQL with descriptor SQLDA, which makes that form of SQL dynamic.
It seems James, the originator, cannot use embedded SQL. </snip>Absolutely! Both methods use the SQLDA, but using the QSQPRCED API isn't the same as using dynamic embedded SQL:
When you use embedded SQL you create a SQL ILE RPG Object (CRTSQLRPGI). This object contains the information about communicating with the database - such as the SQL package to be used, RDB connect method, cursor behaviour, SQL rules, etc... To compile this object I believe you need the DB2 Query Mgr and SQL DevKit (5722ST1 on V5R4M0) installed. You simply place the SQL directives in your program and the SQL pre-compiler creates the appropriate structures for you. You don't even need to know that the SQLDA exists.
When you use the QSQPRCED API you can create a bound RPG program (CRTBNDRPG). The calls via QSQPRCED externalise the interaction with the database so you don't need any special development tools to compile your program object. Like many system APIs - you get it for free, but it just takes a little more work to use it. It is your responsibility to create the SQL package, prepare the statement into the package, describe the result set into the SQLDA, set the parameter markers, open the cursor, fetch the results, and close the cursor. This is mostly achieved through calls to QSQPRCED and is pretty straightforward, if a little confusing at first sight.
So, anybody can run dynamic SQL statements from within their RPG programs - you don't need to use embedded SQL.
Cheers Larry Ducie
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.