SQLDA, Dynamic SQL Method 4 and output host variables
Posted in 1999
Topics: General Discussion
Hi, I need something like this : //######################################################### //------------------- Pro*C++ code : BEGIN ---------------- void foo (const vector<string>& out_variables_names_i) { //============================================================= // Number of of output host variables is unknown until run time //============================================================= // stuff for(; ; ;) { // stuff //==================================================== EXEC SQL FETCH the_cursor INTO <out_variables_names_i>; //==================================================== // stuff } // for // stuff } // void foo (const vector<string>& out_variables_names_i) //------------------- Pro*C++ code : END ------------------ //######################################################### 1. Do *Dynamic SQL Method 4* and *SQLDA (SQL Descriptor Area)* enable to gain it? 2. If they do enable to do it { Do we have to use bind variables or another types? How to use relevant types? } Any hints and examples would be appreciated. Alex Sent via Deja.com http://www.deja.com/ Before you buy.
Alex Vinokur wrote: > > Hi, > > I need something like this : > > //######################################################### > //------------------- Pro*C++ code : BEGIN ---------------- > > void foo (const vector<string>& out_variables_names_i) > { > //============================================================= > // Number of of output host variables is unknown until run time > //============================================================= > // stuff > > for(; ; ;) > { > // stuff > > //==================================================== > EXEC SQL FETCH the_cursor INTO <out_variables_names_i>; > //==================================================== > > // stuff > } // for > > // stuff > } // void foo (const vector<string>& out_variables_names_i) > > //------------------- Pro*C++ code : END ------------------ > //######################################################### > > 1. Do *Dynamic SQL Method 4* and > *SQLDA (SQL Descriptor Area)* > enable to gain it? Yes. You can use the DESCRIBE statement to describe into either an sqlda data structure (Informix specific but more flexible) or into a DESCRIPTOR which is portable. See the ESQL/C Manual for details. > 2. If they do enable to do it > { > Do we have to use bind variables or another types? > How to use relevant types? > } You can FETCH the data into any memory you want, predefined host variables or malloc() memory as you want. You can see the manual. > > Any hints and examples would be appreciated. For examples see the samples directory or any of the many ESQL/C utilities in the IIUG Software Repository. Jonathan Leffler's sqlcmd or any of my utilities in utils2_ak show good use of sqlda dymamic queries. Art S. Kagel