Re: Help - Mailing list pgsql-bugs

From John R Pierce
Subject Re: Help
Date
Msg-id 56EB3D34.3040003@hogranch.com
Whole thread Raw
In response to Help  (Ritanjali M <ritanjalim60@gmail.com>)
Responses Re: Help  ("David G. Johnston" <david.g.johnston@gmail.com>)
List 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

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #14026: Problem to convert number to real
Next
From: Tom Lane
Date:
Subject: Re: BUG #14025: Unable to validate constraints