sqlca.sqlcode after select statement
Posted in 1999
Topics: SQL Development & Query Writing, Error Codes & Troubleshooting
Hi all, I have a quick question for you, hope you can helps! What is the sqlca.sqlcode value after the following SQL statement, if no rows in database satisfy the where clause? $select sum(colA), count(*) from table1 where col_id = $var Thanks kitming
In article <38391597.3D8164A5@hotmail.com>, Low Kit Ming <kmlow72@hotmail.com> wrote: > Hi all, > > I have a quick question for you, hope you can helps! > What is the sqlca.sqlcode value after the following SQL statement, if no > rows in database satisfy the where clause? > > $select sum(colA), count(*) > from table1 > where col_id = $var > > Thanks > kitming > > the sum will be NULL, the count will be 0 and sqlca.sqlcode will be 0. -- # unrm / ksh: unrm: not found # man cpio Sent via Deja.com http://www.deja.com/ Before you buy.
In article <38391597.3D8164A5@hotmail.com>, Low Kit Ming <kmlow72@hotmail.com> wrote: > Hi all, > > I have a quick question for you, hope you can helps! > What is the sqlca.sqlcode value after the following SQL statement, if no > rows in database satisfy the where clause? > > $select sum(colA), count(*) > from table1 > where col_id = $var If you mean "Should I get SQLNOTFOUND back?", the answer is no. If all you select are aggregates (ie COUNT() and SUM()) the count of no rows is zero (0) and the sum of no rows is NULL (unknown) but there is no error and exactly one row is returned so SQLNOTFOUND does not apply. Art S. Kagel Sent via Deja.com http://www.deja.com/ Before you buy.
Low Kit Ming wrote: > I have a quick question for you, hope you can helps! > What is the sqlca.sqlcode value after the following SQL statement, if no > rows in database satisfy the where clause? > > $select sum(colA), count(*) > from table1 > where col_id = $var > I note you've not put the values selected into any variables (no INTO clause). If your database is normal, you will get sqlca.sqlcode == 0. If it is the notorious MODE ANSI database, then you will get the ANSI-mandated SQLNOTFOUND. -- Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net) Guardian of DBD::Informix v0.62 -- see http://www.perl.com/CPAN #include <disclaimer.h>