Re: Get id of a tuple using exception - Mailing list pgsql-sql

From Adrian Klaver
Subject Re: Get id of a tuple using exception
Date
Msg-id 201104140732.09311.adrian.klaver@gmail.com
Whole thread Raw
In response to Get id of a tuple using exception  (f vf <fvalentef@gmail.com>)
List 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 by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Get id of a tuple using exception
Next
From: Steven Dahlin
Date:
Subject: update using recursion