From: | Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com> |
---|---|
To: | f vf <fvalentef(at)gmail(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Get id of a tuple using exception |
Date: | 2011-04-14 14:32:08 |
Message-ID: | 201104140732.09311.adrian.klaver@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(dot)klaver(at)gmail(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Steven Dahlin | 2011-04-14 21:33:16 | update with recursive query |
Previous Message | Adrian Klaver | 2011-04-14 13:23:54 | Re: Get id of a tuple using exception |