Output of PL/PGSQL?

From: David <davidr(at)talamh(dot)org(dot)uk>
To: pgsql-novice(at)postgresql(dot)org
Subject: Output of PL/PGSQL?
Date: 2005-05-04 15:39:47
Message-ID: 0b10811b45ea1f805d8117f4e1885847@talamh.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message operationsengineer1 2005-05-04 16:12:40 Cascade Delete To Override Table Restrict Delete
Previous Message Andrew Hammond 2005-05-04 13:56:10 Re: comparison trigger function