tags:

views:

19

answers:

1

Hi I want to create the schema with the name assigned to the variable. Example:

CREATE OR REPLACE FUNCTION test1("name" character varying)
  RETURNS void AS
'CREATE SCHEMA "name";'
  LANGUAGE 'sql' VOLATILE
  COST 100;
ALTER FUNCTION test1(character varying) OWNER TO postgres;
A: 

You could use plpgsql and than EXECUTE:

CREATE OR REPLACE FUNCTION test1("name" character varying)
RETURNS void AS
$$
BEGIN
    EXECUTE 'CREATE SCHEMA '|| quote_ident($1); -- security

    RETURN;
END;
$$
LANGUAGE plpgsql
VOLATILE
COST 20;
Frank Heikens
Thanks Frank it worked for me.
GVK