I am trying to create table inside POSTGRESQL function but getting following error.
ERROR: no schema has been selected to create in CONTEXT: SQL statement " CREATE TABLE IF NOT EXISTS test.t_testing ( id serial PRIMARY KEY, customerid int, daterecorded date, value double precision )"
My function is as follows.
CREATE OR REPLACE FUNCTION test.create_table_type1(t_name varchar(30))
RETURNS VOID AS
$func$
BEGIN
EXECUTE format('
CREATE TABLE IF NOT EXISTS %I (
id serial PRIMARY KEY,
customerid int,
daterecorded date,
value double precision
)', 'test.t_' || t_name);
END
$func$ LANGUAGE plpgsql;