ExecCommandOk() return code always zero?
От | Richard |
---|---|
Тема | ExecCommandOk() return code always zero? |
Дата | |
Msg-id | 3898D1C8.B2FB101B@sfu.ca обсуждение исходный текст |
Ответы |
Re: [INTERFACES] ExecCommandOk() return code always zero?
|
Список | 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 по дате отправления: