pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Brandl, Wolfgang <wolfgang.brandl@brz.gv.at>
To: pgsql-admin@postgresql.org <pgsql-admin@postgresql.org>
Subject: Re: WG: Extension using the current connection handle
Date: Wed, 13 Dec 2017 15:46:46 +0100
Message-ID: <1513176406.5128.36.camel@cybertec.at> (raw)
In-Reply-To: <F2EB158D72DC6A4F97877DD0BB6F020E61388C03@CMD0MBX-AB01.cmd0.cna.at>
References: <F2EB158D72DC6A4F97877DD0BB6F020E61388C03@CMD0MBX-AB01.cmd0.cna.at>

Wolfgang Brandl wrote:
> I have written a extension in postgres to call a Oracle Stored procedure.
> We have a Postgres table holding the usernames and password related to the Oracle SID.
> 
> In my extension I wanted to select the username and password out of this table.
> Do I have to make a new Postgres connection or can I somehow use the current connection handel from the session Where the extension will be called?

You would use the SPI interface to query database tables from
a C function:
https://www.postgresql.org/docs/current/static/spi.html

If you don't feel like reinventing the wheel, there are tricks how
to do that with oracle_fdw.  You could create an Oracle table with
a BEFORE INSERT trigger that executes the procedure.

See https://stackoverflow.com/a/46360383/6464308

Yours,
Laurenz Albe




view thread (4+ messages)  latest in thread

Message-ID: <1513176406.5128.36.camel@cybertec.at>
Permalink:  ../1513176406.5128.36.camel@cybertec.at/
Also on:    postgresql.org/message-id/1513176406.5128.36.camel@cybertec.at

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: laurenz.albe@cybertec.at, wolfgang.brandl@brz.gv.at
  Subject: Re: WG: Extension using the current connection handle
  In-Reply-To: <1513176406.5128.36.camel@cybertec.at>

* 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