From: | "Oliver Elphick" <olly(at)lfix(dot)co(dot)uk> |
---|---|
To: | DaVinci <bombadil(at)wanadoo(dot)es> |
Cc: | Lista PostgreSql <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: transaction safety |
Date: | 2001-02-12 11:08:55 |
Message-ID: | 200102121108.f1CB8tw00336@linda.lfix.co.uk |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
DaVinci wrote:
> Hi all.
>
> I want to create a new tuple of main info and detail tuples (in
> different tables) that are joined by a key field. Key field is created by
> generator automatically and I need that number in order to assign to detail
> tuples. How can I to get that number in a safe way?.
A successful INSERT returns the oid of the row just created; so get the
new value with a query like this:
SELECT key_field FROM table WHERE oid = new_oid_value;
In libpq programming, use PQoidValue() to get the oid. Other interfcaes
should have equivalent methods.
--
Oliver Elphick Oliver(dot)Elphick(at)lfix(dot)co(dot)uk
Isle of Wight http://www.lfix.co.uk/oliver
PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47 6B 7E 39 CC 56 E4 C1 47
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
========================================
"When I consider thy heavens, the work of thy fingers,
the moon and the stars, which thou hast ordained; What
is man, that thou art mindful of him? and the son of
man, that thou visitest him? For thou hast made him a
little lower than the angels, and hast crowned him
with glory and honour." Psalms 8:3-5
From | Date | Subject | |
---|---|---|---|
Next Message | DaVinci | 2001-02-12 11:34:14 | Re: transaction safety |
Previous Message | DaVinci | 2001-02-12 10:52:42 | transaction safety |