So according to the documentation:
inquiry_directive ::= $$
An inquiry directive can be predefined as described in "Using Predefined Inquiry Directives With Conditional Compilation" or be user-defined. The following describes the order of the processing flow when conditional compilation attempts to resolve an inquiry directive:
idis used as an inquiry directive in the form
idfor the search key.
PLSQL_CCFLAGSinitialization parameter is scanned from right to left, searching with
idfor a matching name (case insensitive); done if found.The predefined inquiry directives are searched; done if found.
idcannot be resolved to a value, then the
PLW-6003warning message is reported if the source text is not wrapped. The literal
NULLis substituted as the value for undefined inquiry directives. Note that if the PL/SQL code is wrapped, then the warning message is disabled so that the undefined inquiry directive is not revealed.
I take this to mean, if you do $IF $$XXX = 5 $THEN .. $END but have not defined $$XXX with "alter session set plsql_ccflags" then you should expect an error.
But I am unable to make this trigger a warning or an error, either by
alter session set plsql_warnings = 'error:06003';
alter session set plsql_warnings = 'enable:all';
SCOTT@ORCL> alter session set plsql_ccflags = ''; Session altered. SCOTT@ORCL> alter session set plsql_warnings = 'enable:all', 'error:06003'; Session altered. BEGIN $IF $$DEBUGON $THEN dbms_output.put_line('debug is on'); $ELSIF NOT $$DEBUGON $THEN dbms_output.put_line('debug is NOT on'); $ELSE dbms_output.put_line('debug is neither on nor off - DEBUGON IS NOT SET!'); $END END; / show errors debug is neither on nor off - DEBUGON IS NOT SET! PL/SQL procedure successfully completed. No errors. SCOTT@ORCL>
I am missing something; it is late after all; thanks
Why are my questions not appearing in the https://forums.oracle.com/community/developer/english/oracle_database/sql_and_pl_sql forum? Maybe replying to it will force it in there....
The compiler warnings don't seem to work for anonymous blocks, only for named objects:
dev1 > alter session set plsql_ccflags = '';
dev1 > alter session set plsql_warnings = 'enable:all';
dev1 > create or replace procedure p as
3 $IF $$DEBUGON $THEN
4 dbms_output.put_line('debug is on');
5 $ELSIF NOT $$DEBUGON $THEN
6 dbms_output.put_line('debug is NOT on');
8 dbms_output.put_line('In procedure');
SP2-0804: Procedure created with compilation warnings
dev1 > show error
Errors for PROCEDURE P:
3/8 PLW-06003: unknown inquiry directive '$$DEBUGON'
5/15 PLW-06003: unknown inquiry directive '$$DEBUGON'
Cheeky! I was quoting from the docs albeit 10.2 (I've noticed, the 10g docs seem to be better written, more informative and easier to read than the 11g docs..almost as if they want to make it harder for us sad folks who are taking the pl/sql certification exams) ...but I've gone back to them and there are only 5 uses of the word "anonymous" in that whole chapter and none of them mention that cc flags aren't used in anonymous blocks.
Although, to be honest, it was a bit dumb of me to have expected them to be; you're not storing a compiled unit; you're compiling and running and discarding