Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WEc64-0001Sv-G2 for pgsql-sql@arkaria.postgresql.org; Sat, 15 Feb 2014 10:03:44 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WEc63-0003aa-A0 for pgsql-sql@arkaria.postgresql.org; Sat, 15 Feb 2014 10:03:43 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WEc61-0003aR-80 for pgsql-sql@postgresql.org; Sat, 15 Feb 2014 10:03:41 +0000 Received: from sam.nabble.com ([216.139.236.26]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WEc5u-0004Oo-Fu for pgsql-sql@postgresql.org; Sat, 15 Feb 2014 10:03:40 +0000 Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1WEc5t-0003uJ-3x for pgsql-sql@postgresql.org; Sat, 15 Feb 2014 02:03:33 -0800 Date: Sat, 15 Feb 2014 02:03:33 -0800 (PST) From: ssylla To: pgsql-sql@postgresql.org Message-ID: <1392458613089-5792154.post@n5.nabble.com> 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> Subject: Re: Trigger function - variable for schema name [SOLVED] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: 1.1 (+) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org 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-tp5788931p5792154.html 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