pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedVariable Substitution for table name
2+ messages / 2 participants
[nested] [flat]
* Variable Substitution for table name
@ 2002-03-16 21:52 Samuel J. Sutjiono <ssutjiono@wc-group.com>
0 siblings, 1 reply; 2+ messages in thread
From: Samuel J. Sutjiono @ 2002-03-16 21:52 UTC (permalink / raw)
To: pgsql-general@postgresql.org; pgsql-sql
Hello all,
Does anybody know whether I can do variable substitution in PostgreSQL function ???
create function Test(text) returns text as '
DECLARE
NewView ALIAS for $1;
BEGIN
For rec_set IN SELECT DeptdID, VendorName
from NewView where (DeptID = iDeptID)
I appreciate any help very much.
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Variable Substitution for table name
@ 2002-03-17 00:07 Stephan Szabo <sszabo@megazone23.bigpanda.com>
parent: Samuel J. Sutjiono <ssutjiono@wc-group.com>
0 siblings, 0 replies; 2+ messages in thread
From: Stephan Szabo @ 2002-03-17 00:07 UTC (permalink / raw)
To: Samuel J. Sutjiono <ssutjiono@wc-group.com>; +Cc: pgsql-general@postgresql.org; pgsql-sql
On Sat, 16 Mar 2002, Samuel J. Sutjiono wrote:
> Hello all,
>
> Does anybody know whether I can do variable substitution in PostgreSQL function ???
In plpgsql you can usually use EXECUTE to build a query string
and run it in place of the plain query, so something like
EXECUTE ''SELECT DeptdID, VendorName
from '' || NewView || '' where DeptId=iDeptID''
in place of the select query.
>
> create function Test(text) returns text as '
> DECLARE
> NewView ALIAS for $1;
>
> BEGIN
>
> For rec_set IN SELECT DeptdID, VendorName
> from NewView where (DeptID = iDeptID)
>
> I appreciate any help very much.
>
>
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2002-03-17 00:07 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-03-16 21:52 Variable Substitution for table name Samuel J. Sutjiono <ssutjiono@wc-group.com>
2002-03-17 00:07 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox