Using dynamic sql parameters in ESQL/C
Posted in 1999
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
Hi, I would like to run prepared statements with unknown parameters (?) from ESQL/C, substituting them in when the statement is executed. Having allocated a descriptor and used it to described the statement I am then using SET DESCRIPTOR (on the same descriptor) to set each of the unknown parameters. When declaring the cursor I get error -254 'incorrect number of parameters'. Any ideas what I am missng or doing wrong? Thanks Will --------------------------------------------------------------- Will Slater Will.Slater@orbis-tech.co.uk Orbis Tel: +44 (0)181 742 1600 www.orbis-tech.co.uk Fax: +44 (0)181 742 2649
Will Slater wrote: > > Hi, > > I would like to run prepared statements with unknown parameters (?) from > ESQL/C, substituting them in when the statement is executed. Having > allocated a descriptor and used it to described the statement I am then > using SET DESCRIPTOR (on the same descriptor) to set each of the unknown > parameters. When declaring the cursor I get error -254 'incorrect number > of parameters'. > > Any ideas what I am missng or doing wrong? Can't tell from here. Review the ESQL sample programs or any of the several excellent ESQL programs in the IIUG Repository that use descriptors (my own use the sqlda structure so they are of limited help). Art S. Kagel
Will Slater wrote: > I would like to run prepared statements with unknown parameters (?) > from ESQL/C, substituting them in when the statement is executed. > Having allocated a descriptor and used it to described the statement > I am then using SET DESCRIPTOR (on the same descriptor) to set each > of the unknown parameters. So far, it all sounds right... > When declaring the cursor I get error -254 > 'incorrect number of parameters'. Declaring? I would expect that to be on OPEN, not DECLARE. > Any ideas what I am missng or doing wrong? Not off the top of my head. The best I can do it point you at a big chunk of code which more or less handles SQL DESCRIPTORs. It's DBD::Informix - the file dbdimp.ec deals with this. There's a good deal or Perl-ism to ignore, but the bind_param code deals with connecting values to cursors and the like... -- Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net) Guardian of DBD::Informix v0.60 -- see http://www.perl.com/CPAN #include <disclaimer.h>