简单问题!!欢迎解答!!
declare
vsql varchar2(4000):= 'select iorder ';
begin
for i in (select cusername from v_getflowdefine)
loop
vsql:=vsql|| ',sum(decode(cusername, '||i.cusername|| ',cusername,0)) ' ' '|| i.cusername;
end loop;
vsql:=vsql|| ' from v_getflowdefine group by iorder ';
execute IMMEDIATE vsql;
commit;
end;
提示错误:未找到预期 FROM 关键字
大家帮忙看下 什么原因?
------解决方案--------------------declare
vsql varchar2(4000):= 'select iorder ';
begin
for i in (select cusername from v_getflowdefine)
loop
vsql:=vsql|| ',sum(decode(cusername, '||i.cusername|| ',cusername,0)) ' ' '|| i.cusername;
end loop;
vsql:=vsql|| ' from v_getflowdefine group by iorder ';
dbms_output.put_line( vsql );--看看执行一下看看sql是什么?
execute IMMEDIATE vsql;
commit;
end;
------解决方案--------------------cusername,0)) ' ' '|| i.cusername;
这里为什么要3个单引号?