Re: Update Using SQLDA (fwd)
Posted in 1998
On Mon, 14 Dec 1998, Madan Mashalkar wrote: > No responses to my question prompts me to ask it again. > To clarify: > > The ESQLC manual does NOT have an example of update using SQLDA. > > When trying to run a statement like > ' update table set * = ("value","value",....) ' > > the error returned is -254. (BTW the statement is valid) > As the manual say, the SQLDA structure has to be filled manually. > This has been done. > > Bue EXECUTE USING SQLDA_VAR gives an error anyway. > In the simplest cases, it was tried to update with just 1 column. > > So the question when rephrased looks like this : > > Can anyone please point out the right direction, by an example ? Tested code which works, but is probably misleading in its simplicity. Note that 7.30 engines with ClientSDK provide a description of the input parameters for an UPDATE statement. I haven't tested to see whether it is the server version or the ClientSDK or ESQL/C version or both which is critical. I'm assuming older software (but an ANSI C compiler): #include "sqltypes.h" static void example(void) { int key = 1; int value = 37; struct sqlda local; struct sqlda *sqlda; struct sqlvar_struct data[2] = { { 0 }, { 0 } }; /* ANSI C compilers */ /* Manufacture a descriptor */ sqlda = &local; local.sqld = 2; local.sqlvar = data; data[0].sqltype = CINTTYPE; data[0].sqldata = (char *)&value; data[0].sqllen = sizeof(int); data[1].sqltype = CINTTYPE; data[1].sqldata = (char *)&key; data[1].sqllen = sizeof(int); EXEC SQL WHENEVER ERROR STOP; EXEC SQL PREPARE s_upd FROM "UPDATE SomeTable SET ValueCol = ? WHERE KeyCol = ?"; EXEC SQL EXECUTE s_upd USING DESCRIPTOR sqlda; } int main() { EXEC SQL WHENEVER ERROR STOP; EXEC SQL DATABASE stores; EXEC SQL WHENEVER ERROR CONTINUE; EXEC SQL CREATE TABLE SomeTable(KeyCol INTEGER, ValueCol INTEGER); EXEC SQL INSERT INTO SomeTable VALUES(1, 21); example(); return 0; } Yours, Jonathan Leffler (jleffler@informix.com) #include <witticism.h> Guardian of DBD::Informix v0.60 -- http://www.perl.com/CPAN Informix IDN for D4GL & Linux -- http://www.informix.com/idn > Date: Fri, 11 Dec 1998 09:51:25 -0800 (PST) > From: Madan Mashalkar <madan@infogain.com> > > I am trying to update an unknown number of columns using > SQLDA. But I keep getting -254 ( No of values dont match) > > Does anyone have a sample program that can be emailed to me, > which does the above (update on unknown column list using SQLDA) ? > > Environment : IDS 7.30 SunSolaris 2.6 ESQL/C 7.24.UC1, OnLine 7.24.UC1, Sun Sparc 20, Solaris 2.6, GCC 2.8.1.