ESQL/C DESCRIBE INTO with insert statement
Posted in 2000
Topics: SQL Development & Query Writing, Error Codes & Troubleshooting, Connectivity: ESQL/C, 4GL & Embedded SQL, Versions, Editions & End-of-Life
According to the manuals, it's legit to describe an insert statement into an sqlda structure. While I can do this with a select statement just fine, attempting the same thing with an insert statement gives me odd errors. There aren't any examples in the books or demo programs that do this exact thing. BTW, this is ESQL/C 9.30.UC1 and IDS 9.20.UC1 on Linux. EXEC SQL PREPARE prep_stmt FROM "insert into foo (a)"; // works fine EXEC SQL DESCRIBE prep_stmt INTO sqlda_ptr; // gives sqlcode of 9 sqlcode of 9 is Bad file number, an OS error code. This seems totally bogus. If I change my statement to "insert into foo (a) values (?)" I get sqlcode of 6 No such device or address, which is equally bogus. So, does anyone know if this is valid, and what I'm doing wrong? My next approach will be to specify the same columns in a select statement and use that for the describe. Then I'll try to insert into the same column list using that sqlda array and hope it works. Thanks! -Larry Sent via Deja.com http://www.deja.com/ Before you buy.
calmate@hotmail.com wrote: > According to the manuals, it's legit to describe an insert statement > into an sqlda structure. While I can do this with a select statement > just fine, attempting the same thing with an insert statement gives me > odd errors. There aren't any examples in the books or demo programs that > do this exact thing. > > BTW, this is ESQL/C 9.30.UC1 and IDS 9.20.UC1 on Linux. > > EXEC SQL PREPARE prep_stmt FROM "insert into foo (a)"; // works fine It shouldn't. You need a VALUES clause or a SELECT statement after it. ...Actually, it may work and may return SQ_LDINSERT, an INSERT statement for use with LOAD. I thought this vanished in the transition to version 4.x - say 12 years ago. I was most displeased with the change since it broke my RDSQL program, a predecessor to SQLCMD. As written, the (a) represents the list of columns in the table foo... > > EXEC SQL DESCRIBE prep_stmt INTO sqlda_ptr; // gives sqlcode of 9 > > sqlcode of 9 is Bad file number, an OS error code. This seems totally > bogus. > > If I change my statement to "insert into foo (a) values (?)" I get > sqlcode of 6 No such device or address, which is equally bogus. > > So, does anyone know if this is valid, and what I'm doing wrong? My next > approach will be to specify the same columns in a select statement and > use that for the describe. Then I'll try to insert into the same column > list using that sqlda array and hope it works. > > Thanks! > > -Larry > > Sent via Deja.com http://www.deja.com/ > Before you buy. -- Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net) Guardian of DBD::Informix v1.00.PC1 -- see http://www.perl.com/CPAN #include <disclaimer.h>