From: | Durumdara <durumdara(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: PG and dynamic statements in stored procedures/triggers? |
Date: | 2011-03-07 14:45:11 |
Message-ID: | AANLkTiksAdX6sGx2jnp-YrqUfO=ufQTRWPyQPxYuJuVL@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi!
Thanks!
How do I create "cursor" or "for select" in PGSQL with dynamic way?
For example
:tbl = GenTempTableName()
insert into :tbl...
insert into :tbl...
insert into :tbl...
for select :part_id from :tbl begin
exec 'select count(*) from subitems where id = ?' using :part_id into
:sumof
update :tbl set sumof = :sumof where part_id=:part_id
end;
Can you show me same example?
Thanks:
dd
2011/3/7 Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>
> On Monday, March 07, 2011 6:32:44 am 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
>
>
> http://www.postgresql.org/docs/9.0/interactive/plpgsql-statements.html#PLPGSQL-
> STATEMENTS-EXECUTING-DYN
> --
> Adrian Klaver
> adrian(dot)klaver(at)gmail(dot)com
>
From | Date | Subject | |
---|---|---|---|
Next Message | Merlin Moncure | 2011-03-07 14:52:22 | Re: pg_dump slow with bytea data |
Previous Message | Vibhor Kumar | 2011-03-07 14:40:01 | Re: PG and dynamic statements in stored procedures/triggers? |