From: | David Johnston <polobo(at)yahoo(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Passing dynamic parameters to a table-returning function |
Date: | 2013-02-04 23:49:45 |
Message-ID: | 1360021785627-5743726.post@n5.nabble.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Moshe Jacobson wrote
> I'm
> unsure of the syntax for passing in values from columns in the database as
> the parameters of a set-returning function from which I want to select *.
General form for this in version <= 9.2:
WITH func_call_cte AS (
SELECT func_call(col1, col2, col3) AS func_result
FROM table_with_cols_123
)
SELECT (func_result).*
FROM func_call_cte;
9.3 will have "LATERAL" and so should be much cleaner.
The general idea is you have to put the function into the select-list so it
can see the columns of the table in the FROM. To avoid multiple evaluations
of the function you have to treat the output set as a single typed column
(func_result) and then in an outer query layer (in this case outside the
WITH) you can generically expand the typed column into its component parts.
HTH,
David J.
--
View this message in context: http://postgresql.1045698.n5.nabble.com/Passing-dynamic-parameters-to-a-table-returning-function-tp5743680p5743726.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Harris | 2013-02-05 00:35:24 | Hot Standby has PANIC: WAL contains references to invalid pages |
Previous Message | Little, Douglas | 2013-02-04 22:35:11 | Reverse Engr into erwin |