Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id D6DAC1337BD7 for ; Thu, 14 Apr 2011 07:56:59 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 09188-03 for ; Thu, 14 Apr 2011 10:56:53 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-px0-f174.google.com (mail-px0-f174.google.com [209.85.212.174]) by mail.postgresql.org (Postfix) with ESMTP id 48C431337BC4 for ; Thu, 14 Apr 2011 07:56:52 -0300 (ADT) Received: by pxi15 with SMTP id 15so1238955pxi.33 for ; Thu, 14 Apr 2011 03:56:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to :content-type; bh=qBidiKYZxkDaPraSrO8P1tWoDMeN81X/IbVrNYU1wWM=; b=KWgsPViavpNh5vHw/YR+PSjS+lUG0h+PekqKPcbUdl4vqHki6IADpPA5puo4qjH8Hk AnMtcpkL6JQPJNSZhQGzhEvIP0Vq+3X1apI93+PN6OFC7f9sozo31+kud4sLEwkrkAgg Xbm9twVlQJ3FeixovtEjSoDcEvtm1KEfb6aSE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=Mr2dlXv0O/GExwuZxEG/bCgmIDh6AQNQqh2HO5coGGOWi8IO2JTvglkwLJh1H/+adf TjqaaVp+GSlhcHlirMEjmE6PKeCKRvRb95p594ljKMl7bftI3gHuCJwdEAefeDmy8nul 7Dy70TRbn8QwF07GfwO3t4VnPKPxee3Zm0ips= MIME-Version: 1.0 Received: by 10.142.154.12 with SMTP id b12mr206261wfe.160.1302778611810; Thu, 14 Apr 2011 03:56:51 -0700 (PDT) Received: by 10.142.186.3 with HTTP; Thu, 14 Apr 2011 03:56:51 -0700 (PDT) Date: Thu, 14 Apr 2011 11:56:51 +0100 Message-ID: Subject: Get id of a tuple using exception From: f vf To: pgsql-sql@postgresql.org Content-Type: multipart/alternative; boundary=000e0cd2bf6a60c30804a0dec84b X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.888 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, T_TO_NO_BRKTS_FREEMAIL=0.01 X-Spam-Level: X-Archive-Number: 201104/17 X-Sequence-Number: 35264 --000e0cd2bf6a60c30804a0dec84b Content-Type: text/plain; charset=ISO-8859-1 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 --000e0cd2bf6a60c30804a0dec84b Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hello,
i'm using a pl/sql procedure and I prevent inserting duplicat= e tuples using an exception for example:

=A0 BEGIN
=A0=A0=A0=A0= =A0=A0 INSERT INTO "Triples"(id, subject, predicate, "object= ")
=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 VALUES (id, s= ub_i, pred_i, obj_i);
=A0EXCEPTION WHEN unique_violation THEN
=A0=A0=A0 =A0=A0=A0 =A0=A0=A0= =A0=A0=A0 --do something.

In some cases I have interest in gett= ing 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 u= sing a select to know wich was the id of the triple already existing in the= table?

Thanks,
Filipe
--000e0cd2bf6a60c30804a0dec84b--