ExecCommandOk() return code always zero? - Mailing list pgsql-interfaces

From Richard
Subject ExecCommandOk() return code always zero?
Date
Msg-id 3898D1C8.B2FB101B@sfu.ca
Whole thread Raw
Responses Re: [INTERFACES] ExecCommandOk() return code always zero?  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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: 0ExecTuplesOk returns: 1Database has 5 record(s)

If I purge all the records in the database, the result of running this
program is:
ExecCommmandOk returns: 0ExecTuplesOk returns: 1Database 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


pgsql-interfaces by date:

Previous
From: Nicolas Huillard
Date:
Subject: RE: [INTERFACES] database migration
Next
From: Craig Orsinger
Date:
Subject: Compiling C Language Functions On WinNT