pl/sql动态执行sql语句时报错:ORA-00911: 无效字符 ORA-06512: 在 line 14
时间:2010-08-27 来源:shuangoracle
今天测试的时候遇到两个错误提醒,写下来给自己提个醒:
--建测试表
create table test_table(tablename varchar2(50),selectsql clob);
insert into test_table values('dual','select sysdate from dual;');
commit;
--pl/sql
SQL> declare
2 cursor c is select selectsql from test_table;
3 cur c%rowtype;
4 v_selectsql varchar2(30000);
5 v_date date;
6 begin
7 open c;
8 fetch c into cur;
9 if c%notfound then
10 return;
11 end if;
12 v_selectsql := cur.selectsql;
13 execute immediate v_selectsql into v_date;
14 dbms_output.put_line(v_date);
15 close c;
16 end;
17 /
ORA-00911: 无效字符
ORA-06512: 在 line 14
--修改测试表test_table中selectsql字段,将最后的 ‘;’ 去掉,再执行:
SQL> /
27-8月 -10
PL/SQL procedure successfully completed