CREATE OR REPLACE FUNCTION trigger_function_test_yum()
RETURNS trigger AS
$BODY$
DECLARE
str_time varchar;
str_sub_tablename varchar;
str_sql_cmd varchar;
BEGIN
IF TG_OP <> 'INSERT' OR TG_TABLE_NAME <>'test_yum' OR TG_WHEN <> 'BEFORE' THEN
RETURN NULL;
END IF;
--Generate Table Name
str_time = date_part('year',NEW.A)::varchar || '_' || CASE WHEN date_part('month',NEW.A) <10 THEN '0' ELSE '' END ||date_part('month',NEW.A)::varchar;
str_sub_tablename = 'test_yum_' || str_time;
--Check if table not created
select * from pg_tables where schemaname = 'public' and tablename=str_sub_
RETURNS trigger AS
$BODY$
DECLARE
str_time varchar;
str_sub_tablename varchar;
str_sql_cmd varchar;
BEGIN
IF TG_OP <> 'INSERT' OR TG_TABLE_NAME <>'test_yum' OR TG_WHEN <> 'BEFORE' THEN
RETURN NULL;
END IF;
--Generate Table Name
str_time = date_part('year',NEW.A)::varchar || '_' || CASE WHEN date_part('month',NEW.A) <10 THEN '0' ELSE '' END ||date_part('month',NEW.A)::varchar;
str_sub_tablename = 'test_yum_' || str_time;
--Check if table not created
select * from pg_tables where schemaname = 'public' and tablename=str_sub_