Search Postgresql Archives

Re: how to pass tablename to a function

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

 



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.


-- 
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