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
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
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$#
> 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_
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$#
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;
EXECUTE 'insert into tmp'||abc|| 'values ( NEW.* )';
This works :)