Output of PL/PGSQL? - Mailing list pgsql-novice

From David
Subject Output of PL/PGSQL?
Date
Msg-id 0b10811b45ea1f805d8117f4e1885847@talamh.org.uk
Whole thread Raw
Responses Re: Output of PL/PGSQL?  (John DeSoi <desoi@pgedit.com>)
List pgsql-novice
Hi

Is it possible to create output from a PL/PGSQL function that looks
like the output of a query? (And how do you do it?)

I want to write dynamic SQL based on some inputs from a web form and
then hand the query results back to the web app. I'm using Zope/Psycopg
on the web layer and it does the mapping of the query columns to
variables in Zope for me, when running plain queries. But a PL/PGSQL
function by default always creates a result with "one column" (named
after the function).

I have an idea how I can format the resulting rows, but I could not
find how I could change the "header". Assuming I can customise the
header, is there a standard way to output also the resulting rows as if
they come from a plain query? (Plain query being a SELECT FROM
statement, instead of a FUNCTION call.)

Also, would a PL/PGSQL function necessarily be a lot slower then a
plain query? (I could write a bunch of queries to cover all possible
input from the form and use Zope to decided which one to run, but this
looks less elegant to me.)

Thanks

DR


pgsql-novice by date:

Previous
From: Andrew Hammond
Date:
Subject: Re: comparison trigger function
Next
From:
Date:
Subject: Cascade Delete To Override Table Restrict Delete