Re: [GENERAL] Concatenate table name in Pl/Pgsql

2013-06-26 Thread Adarsh Sharma
Final Fix : execute 'insert into tmp'||abc|| ' select $1.*' using new; Thanks On Wed, Jun 26, 2013 at 12:18 PM, Adarsh Sharma wrote: > Able to fix but still new error :( > > > test=# CREATE OR REPLACE FUNCTION tmp_trigger_function() > test-# RETURNS TRIGGER AS $$ > test$# DECLARE > test$# s

Re: [GENERAL] Concatenate table name in Pl/Pgsql

2013-06-25 Thread Adarsh Sharma
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|| ' values

Re: [GENERAL] Concatenate table name in Pl/Pgsql

2013-06-25 Thread Adarsh Sharma
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 test$#

Re: [GENERAL] Concatenate table name in Pl/Pgsql

2013-06-25 Thread Ian Lawrence Barwick
> Thanks > > > On Wed, Jun 26, 2013 at 10:52 AM, Ian Lawrence Barwick > wrote: >> >> 2013/6/26 Adarsh Sharma : >> > 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_

Re: [GENERAL] Concatenate table name in Pl/Pgsql

2013-06-25 Thread Adarsh Sharma
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 ; test$#

Re: [GENERAL] Concatenate table name in Pl/Pgsql

2013-06-25 Thread Ian Lawrence Barwick
2013/6/26 Adarsh Sharma : > 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;

Re: [GENERAL] Concatenate table name in Pl/Pgsql

2013-06-25 Thread Adarsh Sharma
EXECUTE 'insert into tmp'||abc|| 'values ( NEW.* )'; This works :)