Thread: Cursors for update.., we have to port an informix 9.x appication using cursors for update

We have to port an application from Informix 9 CSQL to Postgres 8.1 
using Ecpg.

Informix application uses cursors for update to lock all the rows 
involved in those cursor. Then an update my occur ussing Current of.

How we can do this with postgres?

Thanks for the reply.
Jorge


jmadm <jmadm@montevideo.com.uy> writes:
> We have to port an application from Informix 9 CSQL to Postgres 8.1 
> using Ecpg.

> Informix application uses cursors for update to lock all the rows 
> involved in those cursor. Then an update my occur ussing Current of.

> How we can do this with postgres?

You can use SELECT FOR UPDATE in the cursor, I think.  We don't support
WHERE CURRENT OF, so you'll need an alternative strategy for identifying
the row in the UPDATE command; you could use the table's primary key,
or CTID if you don't mind being quite Postgres-specific.
        regards, tom lane


On 12/20/05, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> jmadm <jmadm@montevideo.com.uy> writes:
> > We have to port an application from Informix 9 CSQL to Postgres 8.1
> > using Ecpg.
>
> > Informix application uses cursors for update to lock all the rows
> > involved in those cursor. Then an update my occur ussing Current of.
>
> > How we can do this with postgres?
>
> You can use SELECT FOR UPDATE in the cursor,

in the cursor or instead of the cursor? IIRC, cursors are read only in postgres

--
regards,
Jaime Casanova
(DBA: DataBase Aniquilator ;)


Am Dienstag, 20. Dezember 2005 20:46 schrieb jmadm:
> We have to port an application from Informix 9 CSQL to Postgres 8.1
> using Ecpg.
>
> Informix application uses cursors for update to lock all the rows
> involved in those cursor. Then an update my occur ussing Current of.
>
> How we can do this with postgres?

IIRC there used to be some patches on gborg to implement WHERE CURRENT OF. I 
have no idea though whether they work with 8.1.

Michael
-- 
Michael Meskes
Email: Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes@jabber.org
Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!