Обсуждение: check the execution status of stored procedure

Поиск
Список
Период
Сортировка

check the execution status of stored procedure

От
Yan Cheng Cheok
Дата:
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) {}

Is there any better way, I can check whether the stored procedure had been executed without problem?

Thanks and Regards
Yan Cheng CHEOK





Re: check the execution status of stored procedure

От
Tom Lane
Дата:
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