Re: Get id of a tuple using exception

Поиск
Список
Период
Сортировка
От Adrian Klaver
Тема Re: Get id of a tuple using exception
Дата
Msg-id 201104140623.55068.adrian.klaver@gmail.com
обсуждение исходный текст
Ответ на Get id of a tuple using exception  (f vf <fvalentef@gmail.com>)
Список pgsql-sql
On Thursday, April 14, 2011 3:56:51 am f vf wrote:
> 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?
If the id is the PRIMARY KEY then it would be the same as the id you tried to 
INSERT correct?

> 
> Thanks,
> Filipe

-- 
Adrian Klaver
adrian.klaver@gmail.com


В списке pgsql-sql по дате отправления:

Предыдущее
От: f vf
Дата:
Сообщение: Get id of a tuple using exception
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: Get id of a tuple using exception