Re: check the execution status of stored procedure - Mailing list pgsql-general

From Tom Lane
Subject Re: check the execution status of stored procedure
Date
Msg-id 5003.1262960342@sss.pgh.pa.us
Whole thread Raw
In response to check the execution status of stored procedure  (Yan Cheng Cheok <yccheok@yahoo.com>)
List pgsql-general
Yan Cheng Cheok <yccheok@yahoo.com> writes:
> Currently, I try to call a stored procedure with void returned type.
>     PGresult *res = PQexec(this->getConnection(), "SELECT * FROM create_tables()");
>     if (PQresultStatus(res) != PGRES_COMMAND_OK)
>     {
>         PQclear(res);
>         return false;
>     }

> Since the returned type of stored procedure is void, I will always fall in to the block

> if (PQresultStatus(res) != PGRES_COMMAND_OK) {}

A successful SELECT command will return PGRES_TUPLES_OK, not
PGRES_COMMAND_OK.  Whether the function result is void or not doesn't
change that.

            regards, tom lane

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Rows missing from table despite FK constraint
Next
From: "Greg Sabino Mullane"
Date:
Subject: Re: Server name in psql prompt