CREATE OR REPLACE FUNCTION chkfunction(schemaname text, state text, wallmaterial text, roofmaterial text)
RETURNS text AS
$BODY$
DECLARE
tblinclusion text;
BEGIN
execute'if (SELECT exists( select schema_name FROM information_schema.schemata WHERE schema_name = '||$1 ||') )
then
tblinclusion:="yes";
return tblinclusion;
else
tblinclusion:="no";
return tblinclusion;'
Using schemaname;
END;
$BODY$
LANGUAGE plpgsql
しかし、それはエラーをスローしています:
syntax error at or near "if"
LINE 1: if (SELECT exists( select schema_name FROM information_schem...