I am trying to build a table name dynamicaly in plpgsql function and using the variable to access the table. Here is the code that I have. The following code compiles but does not run.
CREATE OR REPLACE FUNCTION test () RETURNS int8 AS '
DECLARE
my_count INTEGER;
my_table varchar(30);
BEGIN
my_table := "partition_" || to_char(mod (to_number(extract(doy from current_date ),"999"), 45), "99") ;
select into my_count COUNT(*) FROM in_table;
return row_count;
END;
' LANGUAGE plpgsql;
Please help. Thanks