Declare the record data type : Record Data Type « PL SQL « Oracle PL / SQL






Declare the record data type

 
SQL>
SQL> -- declare the record data type
SQL>
SQL>  set serverout on
SQL>
SQL>  declare
  2      type locationRecordType is record (
  3        streetAddress       varchar2(40),
  4        postalCode          varchar2(12),
  5        city                 varchar2(30),
  6        stateProvince       varchar2(25),
  7        countryID           char(2) not null := 'US'
  8      );
  9
 10      myLocation locationRecordType;
 11    begin
 12      myLocation.streetAddress := '4564 Culloden';
 13      myLocation.postalCode := '20190';
 14      myLocation.city := 'Regina';
 15      myLocation.stateProvince := 'SK';
 16      dbms_output.put_line( 'MY LOCATION IS:' );
 17      dbms_output.put_line( myLocation.streetAddress );
 18      dbms_output.put( myLocation.city||', '||myLocation.stateProvince )
 19      dbms_output.put_line( '  '||myLocation.postalCode );
 20      dbms_output.put_line( myLocation.countryID );
 21    end;
 22    /
MY LOCATION IS:
4564 Culloden
Regina, SK  20190
US

PL/SQL procedure successfully completed.

SQL>
SQL>

           
         
  








Related examples in the same category

1.PL/SQL Collections: record type
2.The %ROWTYPE can also be used to create a record based on the structure of a cursor
3.A simple record that holds a person's name, phone number, and birth date and fill data in
4.Load a row in table to record type
5.A record is populated using a SELECT statement
6.declare record with not null attribute
7.Assign a wrong record type
8.This block shows legal and illegal record assignments.
9.How to select into a record.
10.Select into Records
11.Record type
12.Using explicit definition to define record types and a compound record type; and, the use of nested types
13.Nest records, access the names of the nested records by using another component selector, or period