From: | Tino Wildenhain <tino(at)wildenhain(dot)de> |
---|---|
To: | "GIROIRE, Nicolas (COFRAMI)" <nicolas(dot)giroire(at)airbus(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: "returning" in postgresql request |
Date: | 2005-06-09 15:12:44 |
Message-ID: | 1118329964.5605.11.camel@sabrina.peacock.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Am Donnerstag, den 09.06.2005, 16:30 +0200 schrieb GIROIRE, Nicolas
(COFRAMI):
> Hi,
>
> I try to deploy an Application with Oracle Database to a solution with postgresql.
> the Oracle system exists and we use a request which return an int in a variable nb by "returning nb_lock into nb"
>
> UPDATE xdb_ancestors_lock SET nb_lock=nb_lock+1 WHERE doc_id=? AND ele_id=? returning nb_lock INTO nb;
>
> I'd like to know if there is equivalent solution under postgresql or if i'm obliged to do a select before my update.
>
> Best regards,
>
> Nico
>
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');
if you created a sequence and want assign just another free key.
If not, you need SELECT ... FOR UPDATE instead.
--
Tino Wildenhain <tino(at)wildenhain(dot)de>
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2005-06-09 15:19:36 | Re: Postgre "idle" process using 100% CPU |
Previous Message | Tom Lane | 2005-06-09 15:09:42 | Re: Backup Compatibility between minor versions. |