oracle问题!!!看不懂了!!!
begin
for tmpStrTblName in (SELECT Extend_Info FROM omcdb.Extend_Link_Info) loop
begin
EXECUTE IMMEDIATE(tmpStrTblName.Extend_Info);
end;
end loop;
end;
------解决方案--------------------
begin
for tmpStrTblName in (SELECT Extend_Info FROM omcdb.Extend_Link_Info) loop--循环范围是从Extend_Link_Info取所有记录
begin
EXECUTE IMMEDIATE (tmpStrTblName.Extend_Info);--执行表Extend_Link_Info中字段Extend_Link_Info内的sql语句,且该SQL语句必须为update,insert,delete或者为带into的select查询语句
end;
end loop;
end;
------解决方案--------------------EXECUTE IMMEDIATE 是解析并马上执行动态的SQL语句,显式提交
EXECUTE IMMEDIATE(tmpStrTblName.Extend_Info)就是执行小括号中的值
如:
declare
l_depnam varchar2(20) := 'test';
l_locvarchar2(10) := 'baidu';
begin
execute immediate 'insert into dept values(:1, :2, :3)'
using 60, l_depnam, l_loc;
commit;
end;
------解决方案--------------------tmpStrTblName.Extend_Info 这个就是 for tmpStrTblName in (SELECT Extend_Info FROM omcdb.Extend_Link_Info 这个循环查询出来的Extend_Inf字段的值。Extend_Inf这个字段的值应该是一条sql。