From: Pavel Stehule <pavel.stehule@gmail.com>
To: IlGenna <alessio.gennari78@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Call function with dynamic schema name
Date: Sun, 15 Jan 2012 19:27:05 +0100
Message-ID: <CAFj8pRDkMZ3vyFz9-dGJdp2YA5ckiJ0a4Fa1TLw9TOkDu2jZLQ@mail.gmail.com> (raw)
In-Reply-To: <1326649045251-5146739.post@n5.nabble.com>
References: <1326648533548-5146721.post@n5.nabble.com>
<CAFj8pRDHye2Bv8JiTwE07TVkynHJDGiCz9z8naHAGTJkFOFEyQ@mail.gmail.com>
<1326649045251-5146739.post@n5.nabble.com>
2012/1/15 IlGenna <alessio.gennari78@gmail.com>:
> Can you provide me e little example plz?
CREATE SCHEMA s1;
CREATE SCHEMA s2;
CREATE TABLE s1.a1(a int);
CREATE TABLE s2.a1(a int);
CREATE OR REPLACE FUNCTION s1.fx1()
RETURNS int AS $$
BEGIN RETURN (SELECT MAX(a) FROM s1.a1); END
$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION s2.fx1()
RETURNS int AS $$
BEGIN RETURN (SELECT MAX(a) FROM s2.a1); END
$$ LANGUAGE plpgsql;
SET search_path TO s1;
SELECT fx1(); -- returns max from s1.a1;
SET search_path TO s2;
SELECT fx1(); -- returns max from s2.s1;
Regards
Pavel Stehule
>
> Thanks in advance.
>
> Alessio
>
> --
> View this message in context: http://postgresql.1045698.n5.nabble.com/Call-function-with-dynamic-schema-name-tp5146721p5146739.htm...
> Sent from the PostgreSQL - sql mailing list archive at Nabble.com.
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
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-sql@postgresql.org
Cc: pavel.stehule@gmail.com, alessio.gennari78@gmail.com
Subject: Re: Call function with dynamic schema name
In-Reply-To: <CAFj8pRDkMZ3vyFz9-dGJdp2YA5ckiJ0a4Fa1TLw9TOkDu2jZLQ@mail.gmail.com>
References: <1326648533548-5146721.post@n5.nabble.com> <CAFj8pRDHye2Bv8JiTwE07TVkynHJDGiCz9z8naHAGTJkFOFEyQ@mail.gmail.com> <1326649045251-5146739.post@n5.nabble.com> <CAFj8pRDkMZ3vyFz9-dGJdp2YA5ckiJ0a4Fa1TLw9TOkDu2jZLQ@mail.gmail.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