Re: [GENERAL] Variable Substitution for table name - Mailing list pgsql-sql

From Stephan Szabo
Subject Re: [GENERAL] Variable Substitution for table name
Date
Msg-id 20020316160551.W74854-100000@megazone23.bigpanda.com
Whole thread Raw
In response to Variable Substitution for table name  ("Samuel J. Sutjiono" <ssutjiono@wc-group.com>)
List 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.
>
>


pgsql-sql by date:

Previous
From: "Dan Langille"
Date:
Subject: Re: why the big difference on this explain analyze?
Next
From: "Dan Langille"
Date:
Subject: Re: why the big difference on this explain analyze?