将参数传递给plpgsql函数中的EXECUTE
我从下面的函数中得到以下错误:
ERROR: column "_df" does not exist
create or replace function lax()returns setof record as
$$
declare
rs record;
_planunitcode int;
_DF VARCHAR(25);
str text;
begin
_planunitcode:=1;
_DF :='role.planner';
str :='select role from userplanunit where role = _DF';
--str :='select role from userplanunit where role = quote_literal('DF');';quote_ident
for rs in execute str
--for rs in select role from userplanunit where role = _DF
loop
return next rs;
end loop;
return;
end
$$ language 'plpgsql';
I get following error from the function below:
ERROR: column "_df" does not exist
create or replace function lax()returns setof record as
$
declare
rs record;
_planunitcode int;
_DF VARCHAR(25);
str text;
begin
_planunitcode:=1;
_DF :='role.planner';
str :='select role from userplanunit where role = _DF';
--str :='select role from userplanunit where role = quote_literal('DF');';quote_ident
for rs in execute str
--for rs in select role from userplanunit where role = _DF
loop
return next rs;
end loop;
return;
end
$ language 'plpgsql';
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我纠正了这是转义单引号的问题
i rectified it is the problem of escaping the single quote