Re: PG and dynamic statements in stored procedures/triggers? - Mailing list pgsql-general

From Vibhor Kumar
Subject Re: PG and dynamic statements in stored procedures/triggers?
Date
Msg-id 38611944-BEC5-46AD-B922-48D1068C9861@enterprisedb.com
Whole thread Raw
In response to PG and dynamic statements in stored procedures/triggers?  (Durumdara <durumdara@gmail.com>)
List pgsql-general
On Mar 7, 2011, at 8:02 PM, Durumdara wrote:

> Hi!
>
> In other RDBMS I found a way to make dynamic statements.
> I can use variables, or concat the SQL segments, and execute it all.
>
> :tablename = call CreateTempTable;
> insert into :tablename ....
> drop table :tablename
>
> or (FireBird like cursor handling):
>
> sql = "select * from " || :tablename || " where..."
> for select :sql ....
> ...
>
> Can I do same thing in PGSQL too?
>
> Thanks:
>    dd

You can use EXECUTE dynamic Command of plgpsql:
http://www.postgresql.org/docs/8.4/static/plpgsql-statements.html

Thanks & Regards,
Vibhor Kumar
EnterpriseDB Corporation
The Enterprise PostgreSQL Company
vibhor.kumar@enterprisedb.com
Blog:http://vibhork.blogspot.com


pgsql-general by date:

Previous
From: Durumdara
Date:
Subject: PG and dynamic statements in stored procedures/triggers?
Next
From: Adrian Klaver
Date:
Subject: Re: PG and dynamic statements in stored procedures/triggers?