pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: f vf <fvalentef@gmail.com>
To: pgsql-sql@postgresql.org
Subject: Get id of a tuple using exception
Date: Thu, 14 Apr 2011 11:56:51 +0100
Message-ID: <BANLkTik0fUKBcdYEnFeLczA0e6Gmt-3D=g@mail.gmail.com> (raw)

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

view thread (4+ messages)  latest in thread

Message-ID: <BANLkTik0fUKBcdYEnFeLczA0e6Gmt-3D=g@mail.gmail.com>
Permalink:  ../BANLkTik0fUKBcdYEnFeLczA0e6Gmt-3D=g@mail.gmail.com/
Also on:    postgresql.org/message-id/BANLkTik0fUKBcdYEnFeLczA0e6Gmt-3D=g@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: fvalentef@gmail.com
  Subject: Re: Get id of a tuple using exception
  In-Reply-To: <BANLkTik0fUKBcdYEnFeLczA0e6Gmt-3D=g@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox