Re: Get id of a tuple using exception
| От | Adrian Klaver |
|---|---|
| Тема | Re: Get id of a tuple using exception |
| Дата | |
| Msg-id | 201104140732.09311.adrian.klaver@gmail.com обсуждение исходный текст |
| Ответ на | Get id of a tuple using exception (f vf <fvalentef@gmail.com>) |
| Список | pgsql-sql |
On Thursday, April 14, 2011 6:50:57 am f vf wrote: > No, the id is nextval( 'triples_seq'), if I do nothing, so its something > like: > BEGIN > INSERT INTO "Triples"(id, subject, predicate, "object") > VALUES (nextval( 'triples_seq'), sub_i, pred_i, > obj_i); EXCEPTION WHEN unique_violation THEN > --do something. > > The unique constraint is applyied to the subject, predicate and "object" > fields. So, if I try to insert anything that has these 3 fields equal to > any tuple that already exists in the table I want to get the id of the > original tuple. > To your original question I am not aware of a way of returning the id of the offending tuple, other than through a SELECT. -- Adrian Klaver adrian.klaver@gmail.com
В списке pgsql-sql по дате отправления: