Able to fix but still new error :(
test=# CREATE OR REPLACE FUNCTION tmp_trigger_function()
test-# RETURNS TRIGGER AS $$
test$# DECLARE
test$# stmt text;
test$# abc varchar;
test$# BEGIN
test$# select to_char(NEW.a::timestamp,'mmdd') into abc ;
test$# stmt := 'insert into tmp'||abc|| '
Final Fix :
execute 'insert into tmp'||abc|| ' select $1.*' using new;
Thanks
On Wed, Jun 26, 2013 at 12:18 PM, Adarsh Sharma eddy.ada...@gmail.comwrote:
Able to fix but still new error :(
test=# CREATE OR REPLACE FUNCTION tmp_trigger_function()
test-# RETURNS TRIGGER AS $$
test$#
Hi ,
Today i m creating a function that includes dynamic concatenation of a
partitioned table name as below :-
test=# CREATE OR REPLACE FUNCTION tmp_trigger_function()
test-# RETURNS TRIGGER AS $$
test$# DECLARE
test$# tbl_name text;
test$# abc varchar;
test$# BEGIN
test$# tbl_name := 'tmp';
EXECUTE 'insert into tmp'||abc|| 'values ( NEW.* )';
This works :)
2013/6/26 Adarsh Sharma eddy.ada...@gmail.com:
Hi ,
Today i m creating a function that includes dynamic concatenation of a
partitioned table name as below :-
test=# CREATE OR REPLACE FUNCTION tmp_trigger_function()
test-# RETURNS TRIGGER AS $$
test$# DECLARE
test$# tbl_name text;
test$#
Thanks Ian for such a quick response. But my NEW.* will be 10-15 columns
row.
test=# CREATE OR REPLACE FUNCTION tmp_trigger_function()
test-# RETURNS TRIGGER AS $$
test$# DECLARE
test$# stmt text;
test$# abc varchar;
test$# BEGIN
test$# select to_char(NEW.a::timestamp,'mmdd') into abc ;
Thanks
On Wed, Jun 26, 2013 at 10:52 AM, Ian Lawrence Barwick barw...@gmail.com
wrote:
2013/6/26 Adarsh Sharma eddy.ada...@gmail.com:
Hi ,
Today i m creating a function that includes dynamic concatenation of a
partitioned table name as below :-
test=# CREATE OR REPLACE FUNCTION
Passing each column seems not good because if column additon/deletion
happens in future , we also need to change function as well. I think below
will work :-
test=# CREATE OR REPLACE FUNCTION tmp_trigger_function()
test-# RETURNS TRIGGER AS $$
test$# DECLARE
test$# abc varchar;
test$# BEGIN