表名作为PostgreSQL函数参数
CREATE OR REPLACE FUNCTION some_f(param character varying) RETURNS integer AS $$ BEGIN IF EXISTS (select * from quote_ident($1) where quote_ident($1).id=1) THEN return 1; END IF; return 0; END;$$ LANGUAGE plpgsql;select some_f('table_name');
ERROR: syntax error at or near "."LINE 4: ...elect * from quote_ident($1) where quote_ident($1).id=1)... ^********** Error **********ERROR: syntax error at or near "."
select * from quote_ident($1) tab where tab.id=1
:
ERROR: column tab.id does not exist LINE 1: ...T EXISTS (select * from quote_ident($1) tab where tab.id...
quote_ident($1)
where quote_ident($1).id=1
1
quote_ident($1)
jeck猫
相关分类