Re: Trigger function - variable for schema name [SOLVED] - Mailing list pgsql-sql

From ssylla
Subject Re: Trigger function - variable for schema name [SOLVED]
Date
Msg-id 1392458613089-5792154.post@n5.nabble.com
Whole thread Raw
In response to Re: Trigger function - variable for schema name [SOLVED]  (ssylla <stefansylla@gmx.de>)
List pgsql-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-tp5788931p5792154.html
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.



pgsql-sql by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Re: Time AT TIME ZONE: false result using offset instead of time zone name
Next
From: avpro avpro
Date:
Subject: