Re: Help

From: John R Pierce <pierce(at)hogranch(dot)com>
To: Ritanjali M <ritanjalim60(at)gmail(dot)com>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: Help
Date: 2016-03-17 23:26:44
Message-ID: 56EB3D34.3040003@hogranch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 3/17/2016 6:48 AM, Ritanjali M wrote:
>
> I am new to PostgreSQL ,i want to insert record into multiple table in
> a single transaction and i need to get identity value from first table
> and need to insert into second table with same transaction,so please
> help me out with example.
>

this is not a bug, and shouldn't be sent to the pgsql_bugs reporting
mail list.

you probably want to subscribe to and post to the pgsql-general email
list for these sorts of questions....

but, you would do something like..

begin;
insert into firsttable ..... returning id;
insert into secondtable .... values (....including 'id' value
returned by previous query...);
commit;

its up to your application program making these calls to accept the
return value of the first insert and include it in the 2nd insert, the
specifics of doing that are programming language and sql binding specific.

--
john r pierce, recycling bits in santa cruz

In response to

  • Help at 2016-03-17 13:48:32 from Ritanjali M

Responses

  • Re: Help at 2016-03-18 01:11:39 from David G. Johnston

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2016-03-17 23:33:47 Re: BUG #14025: Unable to validate constraints
Previous Message Tom Lane 2016-03-17 23:25:29 Re: BUG #14026: Problem to convert number to real