From: | ssylla <stefansylla(at)gmx(dot)de> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Trigger function - variable for schema name [SOLVED] |
Date: | 2014-02-15 10:03:33 |
Message-ID: | 1392458613089-5792154.post@n5.nabble.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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.
From | Date | Subject | |
---|---|---|---|
Next Message | avpro avpro | 2014-02-15 11:18:12 | |
Previous Message | Bruce Momjian | 2014-02-14 22:02:26 | Re: [SQL] Comparison semantics of CHAR data type |