From: | Vibhor Kumar <vibhor(dot)kumar(at)enterprisedb(dot)com> |
---|---|
To: | Durumdara <durumdara(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: PG and dynamic statements in stored procedures/triggers? |
Date: | 2011-03-07 14:40:01 |
Message-ID: | 38611944-BEC5-46AD-B922-48D1068C9861@enterprisedb.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(dot)kumar(at)enterprisedb(dot)com
Blog:http://vibhork.blogspot.com
From | Date | Subject | |
---|---|---|---|
Next Message | Durumdara | 2011-03-07 14:45:11 | Re: PG and dynamic statements in stored procedures/triggers? |
Previous Message | Adrian Klaver | 2011-03-07 14:39:45 | Re: PG and dynamic statements in stored procedures/triggers? |