这个片段运行没有错误,除非我取消注释for
循环,在这种情况下我得到
Error report:
ORA-06550: line 12, column 41:
PL/SQL: ORA-00942: table or view does not exist
我的问题是为什么在未注释 for 循环时会发生错误?
set serveroutput on
declare
v_sql varchar2(2000);
v_tmp number;
begin
dbms_output.enable(null);
v_sql := 'CREATE TABLE tmp_bank_codes (name varchar2(256), code varchar2(256))';
dbms_output.put_line('Will do ' || v_sql);
execute immediate v_sql;
v_sql := 'INSERT INTO tmp_bank_codes (name, code) VALUES (''Bank of America'', ''BOANY (NY)'')';
dbms_output.put_line('Will do ' || v_sql);
execute immediate v_sql;
--for bank_code in (select name, code from tmp_bank_codes) loop
-- select 1 into v_tmp from dual;
--end loop;
execute immediate 'drop table tmp_bank_codes';
rollback;
end;
/