Why does dbms_sql.parse containing an invalid PL / SQL block with bindings succeed unexpectedly?

The following shows the PL / SQL block below:

SQL> declare 2 i int; 3 begin 4 i := dbms_sql.open_cursor; 5 dbms_sql.parse(i,'begin dontexist; dbms_output.put(''a''); end;',1); 6 dbms_sql.close_cursor(i); 7 end; 8 / declare * FOUT in regel 1: .ORA-06550: Regel 1, kolom 7: PLS-00201: identifier 'DONTEXIST' must be declared. ORA-06550: Regel 1, kolom 7: PL/SQL: Statement ignored. ORA-06512: in "SYS.DBMS_SQL", regel 1120 ORA-06512: in regel 5 

Because I do not have a procedure called DONTEXIST. My question is why is this next PL / SQL block completed successfully?

 SQL> declare 2 i int; 3 begin 4 i := dbms_sql.open_cursor; 5 dbms_sql.parse(i,'begin dontexist; dbms_output.put(:a); end;',1); 6 dbms_sql.close_cursor(i); 7 end; 8 / PL/SQL-procedure is geslaagd. 

The difference is using a binding variable instead of a constant, but I would like to know why this matters.

This is Oracle 12.1.0.2

+5
source share
1 answer

It looks like the syntax syntax is for anon blocks with links, and the full semantic check is deferred to execution.

However, this is not the behavior we want, so error 26669757 is raised.

+4
source

Source: https://habr.com/ru/post/1271095/


All Articles