Re: Postgres function with output parameters and resultset

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: Postgres function with output parameters and resultset
Дата
Msg-id CAKFQuwbZYHvHjk6ET97X=-DSTTtvarAmR6a2hG1rH4OmdeAeFA@mail.gmail.com
обсуждение исходный текст
Ответ на Postgres function with output parameters and resultset  (Arulalan Narayanasamy <arulalan.narayanasamy@gmail.com>)
Список pgsql-general
On Friday, July 20, 2018, Arulalan Narayanasamy <arulalan.narayanasamy@gmail.com> wrote:
Hi,
I need to create a function which should return resultset and output parameters. For example, I need to retrieve all the records from EMP table whose Grade is 'A' as resultset and total number of matched records, Success or Failure flag & Error message as output parameters. Is there a way in Postgres to achieve this? Kindly help!!

A function can return a single two dimensional table - so, not directly.  Though what you describe here seems like over-engineering.  If you really want the count you'd need to add it to the table but the client can count the records in the table easily enough.  Errors can be done separately via RAISE and likewise let the client deal with that as usual.

Otherwise I've found JSON to be useful for non-tabular results.

David J.

В списке pgsql-general по дате отправления:

Предыдущее
От: Arulalan Narayanasamy
Дата:
Сообщение: Postgres function with output parameters and resultset
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: Postgres function with output parameters and resultset