Re: check the execution status of stored procedure

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Yan Cheng Cheok <yccheok(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: check the execution status of stored procedure
Date: 2010-01-08 14:19:02
Message-ID: 5003.1262960342@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Yan Cheng Cheok <yccheok(at)yahoo(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Greg Sabino Mullane 2010-01-08 14:26:45 Re: Server name in psql prompt
Previous Message Tom Lane 2010-01-08 14:08:10 Re: Rows missing from table despite FK constraint