الرياض اوراكل بتاريخ: 2 مايو 2010 تقديم بلاغ مشاركة بتاريخ: 2 مايو 2010 السلام علليكم ما هو conditional compilation فى plsqlدة شرح بالانجليزى بس مقدرتش استبعوبة اوى لانى اول مرة اسمع عنة فياريت حد من الاخوة الافاضل يوضح الامر Conditional Compilation Statements Beginning with Oracle 10g Release 2, you can use conditional compilation. Conditional compilation lets you include debugging logic or special-purpose logic that runs only when session-level variables are set. The following command sets a PL/SQL compile time variable DEBUG equal to 1: ALTER SESSION SET PLSQL_CCFLAGS = 'debug:1'; This command sets a PL/SQL compile time variable DEBUG equal to 1. You should note that the compile-time flag is case insensitive. You can also set compile-time variables to true or false so that they act like Boolean variables. When you want to set more than one conditional compilation flag, you need to use the following syntax: ALTER SESSION SET PLSQL_CCFLAGS = 'name1:value1 [, name(n+1):value(n+1) ]'; The conditional compilation parameters are stored as name and value pairs in the PLSQL_CCFLAG database parameter. The following program uses the $IF, $THEN, $ELSE, $ELSIF, $ERROR, and $END directives that create a conditional compilation code block: BEGIN $IF $$DEBUG = 1 $THEN dbms_output.put_line('Debug Level 1 Enabled.'); $END END; / Conditional code blocks differs from a normal if-then-else code blocks. Most notably, the $END directive closes the block instead of an END IF and semicolon. The $END directive ends a conditional statement. An END IF closes an IF code block. The syntax rules require that closing blocks end with a semicolon or statement terminator. Statement terminators are not conditional lexical units, and their occurrence without a preceding code statement triggers a compile-time error. The $$ symbol denotes a PL/SQL conditional compile-time variable. The ALTER SESSION statement lets you set conditional compile-time variables. You set them in the PLSQL_CCFLAGS session variable. One or many variables are set in PLSQL_CCFLAGS. All variables are constants Chapter 4: Control Structures 105 until the session ends or they are replaced. You replace these variables by reusing the ALTER SESSION statement. All previous conditional compile-time variables cease to exist when you reset the PLSQL_CCFLAGS session variable. The rules governing conditional compilation are set by the SQL parser. You cannot use conditional compilation in SQL object types. This limitation also applies to nested tables and VARRAYs (scalar tables). Conditional compilation differs in functions and procedures. The behavior changes whether the function or procedure has a formal parameter list. You can use conditional compilation after the opening parenthesis of a formal parameter list, like CREATE OR REPLACE FUNCTION conditional_type ( magic_number $IF $$DEBUG = 1 $THEN SIMPLE_NUMBER $ELSE NUMBER $END ) RETURN NUMBER IS BEGIN RETURN magic_number; END; / Alternatively, you can use them after the AS or IS keyword in no-parameter functions or procedures. They can also be used both inside the formal parameter list and after the AS or IS in parameter functions or procedures. Conditional compilation can only occur after the BEGIN keyword in triggers and anonymousblock program units. Please note that you cannot encapsulate a placeholder, or bind variable, inside a conditional compilation block. اقتباس رابط هذا التعليق شارك المزيد من خيارات المشاركة
Recommended Posts
انضم إلى المناقشة
يمكنك المشاركة الآن والتسجيل لاحقاً. إذا كان لديك حساب, سجل دخولك الآن لتقوم بالمشاركة من خلال حسابك.