Re: PG and dynamic statements in stored procedures/triggers?

From: Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Cc: Durumdara <durumdara(at)gmail(dot)com>
Subject: Re: PG and dynamic statements in stored procedures/triggers?
Date: 2011-03-07 14:55:07
Message-ID: 201103070655.08309.adrian.klaver@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Monday, March 07, 2011 6:45:11 am Durumdara wrote:
> 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?

There are examples in the docs at the link provided. Though I would suggest
reading the pl/pgsql documentation from the beginning to get an idea of its
structure.

>
> Thanks:
> dd

--
Adrian Klaver
adrian(dot)klaver(at)gmail(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message yagru_alvarez 2011-03-07 15:14:59 Logic AND between some strings
Previous Message Merlin Moncure 2011-03-07 14:52:22 Re: pg_dump slow with bytea data