From: Stephan Szabo <sszabo@megazone23.bigpanda.com>
To: Samuel J. Sutjiono <ssutjiono@wc-group.com>
Cc: pgsql-general@postgresql.org
Cc: pgsql-sql@postgresql.org
Subject: Re: Variable Substitution for table name
Date: Sat, 16 Mar 2002 16:07:59 -0800 (PST)
Message-ID: <20020316160551.W74854-100000@megazone23.bigpanda.com> (raw)
In-Reply-To: <00e901c1cd34$edd88cb0$110a010a@headquarters.wcgroup.com>
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.
>
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: sszabo@megazone23.bigpanda.com, ssutjiono@wc-group.com, pgsql-general@postgresql.org
Subject: Re: Variable Substitution for table name
In-Reply-To: <20020316160551.W74854-100000@megazone23.bigpanda.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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