Re: Cross DB insert with returning id

From: Peter Devoy <peter(at)3xe(dot)co(dot)uk>
To: Ritanjali M <ritanjalim60(at)gmail(dot)com>
Cc: "Psql_General (E-mail)" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Cross DB insert with returning id
Date: 2016-04-14 14:30:26
Message-ID: CABoFc_hxB4z+dWKAiYQYdamAPuFDRsLEZqnNNZ0L5mzp890qaw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

You may wish to consider using the Postgres Foreign Data Wrapper to
access your other database:

http://www.postgresql.org/docs/9.3/static/postgres-fdw.html

And then use RETURNING to get your ID, e.g.:

INSERT INTO distributors (did, dname) VALUES (DEFAULT, 'XYZ Widgets')
RETURNING did;

http://www.postgresql.org/docs/9.3/static/sql-insert.html

Kind regards

Peter

On 14 April 2016 at 14:50, Ritanjali M <ritanjalim60(at)gmail(dot)com> wrote:
> Hi Team,
>
> I am new to postgresql ,i need to create one function where i have to insert
> data into cross database table from that table identity value i need to
> insert some other table other database within one function .i am able to
> insert the data into cross DB table using dblink_exec but i unable to get
> the identity value ,so how could i will get identity value from cross
> DB.please help me out with the example.
>
> --
> Thanks & Regards
> Ritanjali Majhee

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Kevin Burke 2016-04-14 17:34:08 Re: Deadlock between VACUUM and ALTER TABLE commands
Previous Message Adrian Klaver 2016-04-14 14:25:50 Re: Site down