Re: "returning" in postgresql request - Mailing list pgsql-general

From Matt Miller
Subject Re: "returning" in postgresql request
Date
Msg-id 1118332976.3596.16.camel@dbamm01-linux
Whole thread Raw
In response to Re: "returning" in postgresql request  (Tino Wildenhain <tino@wildenhain.de>)
List pgsql-general
> > deploy an Application with Oracle Database to a solution with postgresql.
> > ...
> > UPDATE xdb_ancestors_lock SET nb_lock=nb_lock+1 WHERE doc_id=? AND >
> > ele_id=? returning nb_lock INTO nb;

> Looks like you really want:
>
> UPDATE xdb_ancestors_lock SET nb_lock=nextval('nb_lock_sequence') WHERE
> doc_id=? AND ele_id=?;
> SELECT currval('nb_lock_sequence');


We have similar code in our Oracle-but-hopefully-soon-to-be-PostgreSQL
apps.  However, in our case the sequence generator is used in an insert
trigger to populate a column.  So, although I could use "currval" after
the insert to see what the trigger used, that would force the currval-
invoking code to know the internals of the insert trigger.  This is a
bit of an abstraction violation, I think.

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Postgre "idle" process using 100% CPU
Next
From: "Jim C. Nasby"
Date:
Subject: Re: database auto-commit