Oracle PL/SQL/PL SQL/Variable Default Value

Материал из SQL эксперт
Перейти к: навигация, поиск

Assign varaible default value to a varchar variable

SQL>
SQL>  declare
  2      value1 varchar2(100);
  3      value2 varchar2(100) := "";
  4      value3 varchar2(100) := null;
  5      value4 varchar2(100) default null;
  6    begin
  7      null;
  8      dbms_output.put_line( value1 );
  9      dbms_output.put_line( value2 );
 10      dbms_output.put_line( value3 );
 11      dbms_output.put_line( value4 );
 12    end;
 13    /
PL/SQL procedure successfully completed.
SQL>
SQL>



Define default value for number variable

SQL>
SQL> -- assign default value
SQL>
SQL>  declare
  2      l_days_in_week   constant number := 7;
  3      l_weeks_in_month number default 4;
  4    begin
  5      l_weeks_in_month := 5;
  6      dbms_output.put_line(" l_weeks_in_month " || l_weeks_in_month);
  7      dbms_output.put_line(" l_weeks_in_month " || l_weeks_in_month);
  8    end;
  9    /
l_weeks_in_month 5
l_weeks_in_month 5
PL/SQL procedure successfully completed.
SQL>