Oracle10g provides a new feature that is very convenient for developers-selective compilation. That is, only part of the code in PL/SQL can be compiled through the condition. If you are familiar with C ++, you will feel very cordial about this feature, because it is very similar to the conditional Macros in C ++. When 9i is used, developers add their debugging information to the program, which is often not deleted after release. This information affects readability and system performance in severe cases. With this feature, this problem can be solved. The following is a simple example: Create a function with conditional macros: SQL> CREATE OR REPLACE FUNCTION F_TESTDEBUG 2 RETURN NUMBER IS 3 v_count number; 4 BEGIN 5 select count(*) into v_count from user_tables; 6 7 $IF $$my_debug $THEN 8 DBMS_OUTPUT.PUT_LINE('Tables number is: ' || v_count); 9 $END 10 11 return v_count; 12 END; 13 / Function created Activate debug information (controlled by the variable $ my_debug ): SQL> ALTER FUNCTION F_TESTDEBUG COMPILE PLSQL_CCFLAGS = 'my_debug:TRUE' REUSE SETTINGS; Function altered Run the function: SQL> set serveroutput on SQL> declare 2 v_res number; 3 begin 4 v_res: = f_testdebug; 5 end; 6/ Tables number is: 22 PL/SQL procedure successfully completed At this time, we can see that the debug information is printed out. Let's remove the debugging information: SQL> alter function f_testdebug compile plsql_ccflags = 'my _ Debug: false' reuse settings; Function altered Execute the function: SQL> declare 2 v_res number; 3 begin 4 v_res: = f_testdebug; 5 end; 6/ PL/SQL procedure successfully completed We can see that the debugging information is gone. Of course, we do not need to use alter in actual release (unless on-site debugging). You can define the my_debug variable in the header of the release script. |