From: Richard <blackw@sfu.ca>
To: pgsql-interfaces@postgresql.org
Subject: ExecCommandOk() return code always zero?
Date: Wed, 02 Feb 2000 16:54:32 -0800
Message-ID: <3898D1C8.B2FB101B@sfu.ca> (raw)
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: blackw@sfu.ca
Subject: Re: ExecCommandOk() return code always zero?
In-Reply-To: <3898D1C8.B2FB101B@sfu.ca>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox