Create types and then use it in pl/sql block : Object « Object Oriented Database « Oracle PL / SQL






Create types and then use it in pl/sql block

    

SQL>
SQL> CREATE OR REPLACE TYPE unitType AS VARRAY(13) OF VARCHAR2(5 CHAR);
  2  /

Type created.

SQL> CREATE OR REPLACE TYPE categoryType AS VARRAY(4) OF VARCHAR2(8 CHAR);
  2  /

Type created.

SQL> CREATE OR REPLACE TYPE charArrayType AS TABLE OF VARCHAR2(17 CHAR);
  2  /

Type created.

SQL>
SQL> DECLARE
  2    counter INTEGER := 0;
  3
  4    suits categoryType :=categoryType('A','B','C','D');
  5    units unitType :=unitType('1','2','3','4','Five','Six','Seven');
  6
  7    charArray charArrayType := charArrayType();
  8  BEGIN
  9
 10
 11
 12    FOR i IN 1..counter LOOP
 13      dbms_output.put_line('['||charArray(i)||']');
 14    END LOOP;
 15  END;
 16  /

PL/SQL procedure successfully completed.

   
    
    
    
  








Related examples in the same category

1.Create Object
2.CREATE OR REPLACE TYPE
3.Create a stored type which is visible to SQL and PL/SQL.
4.reference user-defined data type in another block
5.Student type
6.Point type
7.Use user-defined type as parameter
8.This script demonstrates complex objects
9.Name type
10.Behavior of dependent objects.
11.Build data type with another user type
12.Create the object and collection types
13.Create type and use it in inner query
14.Combine user-defined type to create new type
15.PriceType becomes the datatype of the price attribute in the ProductType object type
16.Use self to reference member variable in constructor
17.One to list using object references