unknown column list for INSERT in esql/c
Posted in 1997
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
------------73A2B511D181 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii Do anyone of you ESQL pros have an example on how to use unspecified column lists for inserts? That is, how to insert a record into a table that is not specified at compile time. This is a sketch of what I have which does not quite work: EXEC SQL BEGIN DECLARE SECTION; char sqlquery[80]; EXEC SQL END DECLARE SECTION; struct sqlda *ifx_sqlda_ptr; int columns; EXEC SQL connect to 'stores7'; sprintf(sqlquery,"INSERT INTO state (code) VALUES ('aa') "); EXEC SQL prepare iqid from :sqlquery ; printf("prepare sqlstate: %s\\n",SQLSTATE); EXEC SQL describe iqid into ifx_sqlda_ptr; printf("describe sqlstate: %s\\n",SQLSTATE); columns = ifx_sqlda_ptr->sqld; The result is SQLSTATE is always 00000, however, columns is zero as well? I would expect the describe statement would fill the sqlda structure with the relevant information from the sql statement - but it doesn't. (Page 10-106 of the Programmer's guide gives an outline of what must be done - unfortunately, it is unclear to me). Thanks in advance, Michael Athanas The Nile Project Cornell University ------------73A2B511D181 Content-Transfer-Encoding: 7bit Content-Type: text/html; charset=us-ascii <HTML><BODY> <DT>Do anyone of you ESQL pros have an example on how to use unspecified column lists for inserts? That is, how to insert a record into a table that is not specified at compile time.</DT> <DT> </DT> <DT>This is a sketch of what I have which does not quite work:</DT> <DT> </DT> <DT> EXEC SQL BEGIN DECLARE SECTION; </DT> <DT> char sqlquery[80]; </DT> <DT> EXEC SQL END DECLARE SECTION; </DT> <DT> struct sqlda *ifx_sqlda_ptr;</DT> <DT> int columns;</DT> <DT> </DT> <DT> EXEC SQL connect to 'stores7';</DT> <DT> </DT> <DT> sprintf(sqlquery,"INSERT INTO state (code) VALUES ('aa') "); </DT> <DT> EXEC SQL prepare iqid from :sqlquery ; </DT> <DT> printf("prepare sqlstate: %s\\n",SQLSTATE); </DT> <DT> EXEC SQL describe iqid into ifx_sqlda_ptr; </DT> <DT> printf("describe sqlstate: %s\\n",SQLSTATE);</DT> <DT> columns = ifx_sqlda_ptr->sqld;</DT> <DT> </DT> <DT> The result is SQLSTATE is always 00000, however, columns is zero as well? </DT> <DT>I would expect the describe statement would fill the sqlda structure with the relevant information from the sql statement - but it doesn't. (Page 10-106 of the</DT> <DT>Programmer's guide gives an outline of what must be done - unfortunately, it</DT> <DT>is unclear to me).</DT> <DT> </DT> <DT>Thanks in advance,</DT> <DT> </DT> <DT>Michael Athanas</DT> <DT>The Nile Project</DT> <DT>Cornell University</DT> </BODY> </HTML> ------------73A2B511D181--