Declare scalars based on the datatype of a previously declared variable : Type « PL SQL « Oracle PL / SQL






Declare scalars based on the datatype of a previously declared variable

  

SQL>
SQL>
SQL> --%TYPE attribute
SQL>
SQL> --Declare scalars based on the datatype of a previously declared variable.
SQL>
SQL>
SQL> DECLARE
  2     x NUMBER(7,2) := 100;
  3     y x%TYPE;
  4  BEGIN
  5     y := 200;
  6
  7     DBMS_OUTPUT.PUT_LINE(x);
  8     DBMS_OUTPUT.PUT_LINE(y);
  9  END;
 10
 11  /
100
200

PL/SQL procedure successfully completed.

SQL>

           
         
    
  








Related examples in the same category

1.rowtype and type
2.Select only one row for column type variable
3.Creating a procedure and call it
4.Passing %TYPE and %ROWTYPE as Parameters
5.Column%type parameter
6.reference table data with tableName.columnName%type
7.Add row to table with tableName.columnName%type