Search Postgresql Archives

Re: returning array from function or "structured error"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ivan Sergio Borgonovo wrote:
Building up a temp table and returning a "setof record"
You can avoid the temp table and return `setof record'. Just `RETURN NEXT temp_result' after each test, where temp_result is your declared working variable. When you're done with all tests, do the final RETURN. No need for temp tables anywhere - your PHP invokes the function as `SELECT * FROM test_something(args)' and gets a normal resultset back, just as if it'd performed a SELECT from a table.

Personally, though I'd:

CREATE TYPE test_result AS (  test_id INTEGER, test_outcome TEXT );

or whatever's appropriate for your use, then declare the function as `RETURNS SETOF test_result'.

--
Craig Ringer

--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux