下面的PL/SQL块中的第一个和第二个“put_line”语句会成功,但最后一个失败。为什么?它可能是一个错误?为什么最后的PL/SQL语句使用dbms_assert.enquote_literal失败?
declare
x varchar2(100);
begin
x := 'Test''';
dbms_output.put_line('x is: ' || x || ', enquoted x is: ' || dbms_assert.enquote_literal(replace(x, '''', '''''')));
x := 'Te''st';
dbms_output.put_line('x is: ' || x || ', enquoted x is: ' || dbms_assert.enquote_literal(replace(x, '''', '''''')));
x := '''Test';
dbms_output.put_line('x is: ' || x || ', enquoted x is: ' || dbms_assert.enquote_literal(replace(x, '''', '''''')));
end;
/
的错误是:
Error report:
ORA-06502: PL/SQL: numeric or value error
ORA-06512: at "SYS.DBMS_ASSERT", line 317
ORA-06512: at "SYS.DBMS_ASSERT", line 381
ORA-06512: at line 11
06502. 00000 - "PL/SQL: numeric or value error%s"
*Cause:
*Action:
任何想法?
因为它似乎与变量中的第一个字符有关。如果第一个字符是'',则抛出它。 – SomeJavaGuy
查看dbms_assert的源代码。 –
感觉像马车行为。 – sstan