From: | Richard <blackw(at)sfu(dot)ca> |
---|---|
To: | pgsql-interfaces(at)postgresql(dot)org |
Subject: | ExecCommandOk() return code always zero? |
Date: | 2000-02-03 00:54:32 |
Message-ID: | 3898D1C8.B2FB101B@sfu.ca |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-interfaces |
I've got a little test program that I'm playing with, and am finding an
unusual behaviour. When I query the database with an ExecCommandOk(),
it always returns zero. If I query the database with an ExecTuplesOk(),
it always returns 1 (regardless of whether or not there are any records
in the database).
Here is my little test program:
#include <stdio.h>
#include <pgdatabase.h>
int main(void);
int main()
{
PgDatabase myDB("host=localhost port=5432 dbname=test");
printf("ExecCommandOk returns: %d\n", myDB.ExecCommandOk("select *
from mytable");
printf("ExecTuplesOk return: %d\n", myDB.ExecTuplesOk("select * from
mytable");
printf("Database has %d record(s)\n", myDB.Tuples());
return 0;
}
If I have, say, five records in the database, the result of running this
program is:
ExecCommandOk returns: 0
ExecTuplesOk returns: 1
Database has 5 record(s)
If I purge all the records in the database, the result of running this
program is:
ExecCommmandOk returns: 0
ExecTuplesOk returns: 1
Database has 0 record(s)
Why would ExecCommandOk() and ExecTuplesOk() be returning these
consistent values? The docs indicate the ExecCommandOk() should be
returning TRUE instead of FALSE, and ExecTuplesOk() should only be
returning TRUE if there are tuples to be retreived.
Thanks for your insight.
Cheers,
Richard
From | Date | Subject | |
---|---|---|---|
Next Message | Craig Orsinger | 2000-02-03 01:28:07 | Compiling C Language Functions On WinNT |
Previous Message | Nicolas Huillard | 2000-02-02 20:05:41 | RE: [INTERFACES] database migration |