Get id of a tuple using exception

From: f vf <fvalentef(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Get id of a tuple using exception
Date: 2011-04-14 10:56:51
Message-ID: BANLkTik0fUKBcdYEnFeLczA0e6Gmt-3D=g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello,
i'm using a pl/sql procedure and I prevent inserting duplicate tuples using
an exception for example:

BEGIN
INSERT INTO "Triples"(id, subject, predicate, "object")
VALUES (id, sub_i, pred_i, obj_i);
* EXCEPTION WHEN unique_violation THEN
--do something.

*In some cases I have interest in getting the id of the tuple that was
already in the table when the exception is triggered. Is there a way for the
EXCEPTION to return that id instead of using a select to know wich was the
id of the triple already existing in the table?

Thanks,
Filipe

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Adrian Klaver 2011-04-14 13:23:54 Re: Get id of a tuple using exception
Previous Message Volkmar Herbst GCI 2011-04-13 19:59:01 strange update behavior