From: | David G Johnston <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: how to pass tablename to a function |
Date: | 2014-09-05 00:23:28 |
Message-ID: | 1409876608374-5817871.post@n5.nabble.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
alecinvan wrote
> I like to pass the tablename to function but not using execute clause,
> here is my script
>
> [...]
>
> I want to pass the _tbl to the select query integrated in the unpacking(),
> how can I make it?
There is no way to perform a query with an unknown, at design time,
identifier without using EXECUTE.
The recommended way to do this is to use "format()" and dollar-quoting -
v9.1+ required:
v_qry := format(
$qry$
WITH [...]
SELECT id, func(...) FROM %I WHERE id [...]
$qry$
, _tbl
);
RETURN QUERY EXECUTE v_qry;
David J.
--
View this message in context: http://postgresql.1045698.n5.nabble.com/how-to-pass-tablename-to-a-function-tp5817864p5817871.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.
From | Date | Subject | |
---|---|---|---|
Next Message | Vinayak | 2014-09-05 05:00:31 | CONCAT function |
Previous Message | Adrian Klaver | 2014-09-04 23:57:09 | Re: how to pass tablename to a function |