pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: John R Pierce <pierce@hogranch.com>
To: Ritanjali M <ritanjalim60@gmail.com>
To: pgsql-bugs@postgresql.org
Subject: Re: Help
Date: Thu, 17 Mar 2016 16:26:44 -0700
Message-ID: <56EB3D34.3040003@hogranch.com> (raw)
In-Reply-To: <CAOuzsCSSVFTRta1ZGds1gd1JDXKqMhiB4tPbjPFe7kbwmKvVQw@mail.gmail.com>
References: <CAOuzsCSSVFTRta1ZGds1gd1JDXKqMhiB4tPbjPFe7kbwmKvVQw@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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



-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (38+ messages)  latest in thread

Message-ID: <56EB3D34.3040003@hogranch.com>
Permalink:  ../56EB3D34.3040003@hogranch.com/
Also on:    postgresql.org/message-id/56EB3D34.3040003@hogranch.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: pierce@hogranch.com, ritanjalim60@gmail.com
  Subject: Re: Help
  In-Reply-To: <56EB3D34.3040003@hogranch.com>
  References: <CAOuzsCSSVFTRta1ZGds1gd1JDXKqMhiB4tPbjPFe7kbwmKvVQw@mail.gmail.com> <56EB3D34.3040003@hogranch.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox