Re: sqlca.sqlcode after select statement
Posted in 1999
Topics: SQL Development & Query Writing, Error Codes & Troubleshooting
You're right. I left out the "INTO " clause part in my previoue mail. The correct SQL statement is: $select sum(colA), count(*) into $sum_val, $count_val from table1 where col_id = $var BTW, how to determine whether the database is normal informix or MODE ANSI informix database? Thanks for your helps! Jonathan Leffler wrote: > 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>
Two question arising from my answer -- this is the easy one. When you do CONNECT or when you execute the DATABASE statement, the warning fields in the sqlca record tell you a lot about the database -- is it OnLine, does it have a transaction log, is it MODE ANSI, etc. You have to look at this information before the next SQL statement, of course. Low Kit Ming wrote: > You're right. I left out the "INTO " clause part in my previoue mail. > The correct SQL statement is: > > $select sum(colA), count(*) > into $sum_val, $count_val > from table1 > where col_id = $var > > BTW, how to determine whether the database is normal informix or MODE ANSI > informix database? > Thanks for your helps! > > Jonathan Leffler wrote: > > > 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> -- Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net) Guardian of DBD::Informix v0.62 -- see http://www.perl.com/CPAN #include <disclaimer.h>