oracle游标处理数据库中表
declare vartablename varchar2(8000);
vartablespacename varchar2(8000);
strsql varchar2(8000);
CURSOR mycur is SELECT TABLE_NAME,TABLESPACE_NAME FROM USER_TABLES where TABLE_NAME like 'DMGC_%';
begin
if mycur%isopen = false then
open mycur;
end if;
fetch mycur into vartablename,vartablespacename;
while mycur%found
loop
strsql := 'update '||vartablename||' set sfsh=decode(sfsh,null,''1'',''0''),gxbz=''0''';
begin
-- dbms_output.put_line(strsql);
EXECUTE IMMEDIATE strsql;
exception
when others then
dbms_output.put_line(strsql);
end;
fetch mycur into vartablename,vartablespacename;
end loop;
close mycur;
end;
vartablespacename varchar2(8000);
strsql varchar2(8000);
CURSOR mycur is SELECT TABLE_NAME,TABLESPACE_NAME FROM USER_TABLES where TABLE_NAME like 'DMGC_%';
begin
if mycur%isopen = false then
open mycur;
end if;
fetch mycur into vartablename,vartablespacename;
while mycur%found
loop
strsql := 'update '||vartablename||' set sfsh=decode(sfsh,null,''1'',''0''),gxbz=''0''';
begin
-- dbms_output.put_line(strsql);
EXECUTE IMMEDIATE strsql;
exception
when others then
dbms_output.put_line(strsql);
end;
fetch mycur into vartablename,vartablespacename;
end loop;
close mycur;
end;