Translating with DrWatson… this can take a few seconds the first time.
This is a genuine, complex translation. DrWatson protects commands, error codes, and log output while naturally translating the surrounding text. It’s translated once and saved.
Low Kit Ming asked what sqlca.sqlcode is after selecting SUM and COUNT(*) when no rows match. A poster and Art Kagel answered that sqlcode is 0, not SQLNOTFOUND: the sum is NULL, the count is 0, and exactly one row returns. Jonathan Leffler added that this holds for a normal database, while a MODE ANSI database returns SQLNOTFOUND.
Auto-generated by Claude from the posts below — may be imperfect; read the full thread.
Low Kit Ming — — source: Informix-list mailing list archive (1991-1998)
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.
↪ replying to Low Kit Ming
akagel@my-deja.com — — source: Informix-list mailing list archive (1991-1998)
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.
↪ replying to Low Kit Ming
Jonathan Leffler — — source: Informix-list mailing list archive (1991-1998)
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>
Your privacy choices
We use strictly necessary cookies to make this site work. With your
consent we’d also use optional cookies for analytics and marketing. You can accept all,
reject all, or choose. Read our Cookie Policy.