agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: ssylla <stefansylla@gmx.de>
To: pgsql-sql@postgresql.org
Subject: Re: Trigger function - variable for schema name [SOLVED]
Date: Sat, 15 Feb 2014 02:03:33 -0800 (PST)
Message-ID: <1392458613089-5792154.post@n5.nabble.com> (raw)
In-Reply-To: <1390890403536-5789155.post@n5.nabble.com>
References: <1390811996770-5788931.post@n5.nabble.com>
	<1390819626.71225.YahooMailNeo@web133206.mail.ir2.yahoo.com>
	<1390820451.59644.YahooMailNeo@web133202.mail.ir2.yahoo.com>
	<1390890403536-5789155.post@n5.nabble.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>

I even found another way of doing it, since Postgres 9.1 you it is possible
to use "execute format" which seems a little easier to use than the method
with the string concatenation parameters:

CREATE OR REPLACE FUNCTION trigger_function1()
  RETURNS trigger AS
$$
    begin
        execute format('
               select table2.id from %I.table2
               where value1=%L
               ', TG_TABLE_SCHEMA, new.value1) using new
               into new.id;
     return new;
end:
$$
language plpgsql;

"%I" replaces the quote_ident method and "%L" the quote_literal method.



--
View this message in context: http://postgresql.1045698.n5.nabble.com/SOLVED-Trigger-function-variable-for-schema-name-tp5788931p5...
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



view thread (5+ messages)

Message-ID: <1392458613089-5792154.post@n5.nabble.com>
Permalink:  ../1392458613089-5792154.post@n5.nabble.com/
Also on:    postgresql.org/message-id/1392458613089-5792154.post@n5.nabble.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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: stefansylla@gmx.de
  Subject: Re: Trigger function - variable for schema name [SOLVED]
  In-Reply-To: <1392458613089-5792154.post@n5.nabble.com>

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

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