On Mon, May 2, 2022 at 4:24 PM Robert Stanford wrote:
> On Tue, 3 May 2022 at 08:39, David G. Johnston
> wrote:
>
>> You basically have to use "INSERT ... RETURNING" or variables. Which/how
>> depends on the language you are writing in. Pure SQL without client
>> involvement requires that you
On Tue, 3 May 2022 at 08:39, David G. Johnston
wrote:
> You basically have to use "INSERT ... RETURNING" or variables. Which/how
> depends on the language you are writing in. Pure SQL without client
> involvement requires that you use chained CTEs of INSERT...RETURNING (or I
> suppose you could
On Mon, May 2, 2022 at 3:33 PM Robert Stanford wrote:
>
> --insert statement as single transaction returning contactid
> INSERT INTO contact(
> firstname, lastname)
> VALUES('John', 'Smith');
> INSERT INTO contactinterests(
> contactid, interest)
> VALUES (currval('contact_contactid_s
Hi,
When doing an insert with a serial primary key we can refer to
currval('sequence_name') in subsequent inserts and we also return it for
later processing.
Example:
CREATE TABLE contact (
contactid serial not null primary key, -- creates sequence
'contact_contactid_seq'
firstname text n