On Friday, July 20, 2018, Arulalan Narayanasamy < arulalan.narayanas...@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.