declare record with not null attribute : Record Data Type « PL SQL « Oracle PL / SQL

declare record with not null attribute

SQL>  set serverout on
SQL>  declare
  2      type location_record_type is record (
  3        street_address       varchar2(40),
  4        postal_code          varchar2(12),
  5        city                 varchar2(30),
  6        state_province       varchar2(25),
  7        country_id           char(2) not null := 'US'
  8      );
 10      l_my_loc location_record_type;
 11    begin
 12      l_my_loc.street_address := '1 Oracle Way';
 13      l_my_loc.postal_code := '20190';
 14 := 'Reston';
 15      l_my_loc.state_province := 'VA';
 16      dbms_output.put_line( 'MY LOCATION IS:' );
 17      dbms_output.put_line( l_my_loc.street_address );
 18      dbms_output.put(||', '||l_my_loc.state_province );
 19      dbms_output.put_line( '  '||l_my_loc.postal_code );
 20      dbms_output.put_line( l_my_loc.country_id );
 21    end;
 22    /
1 Oracle Way
Reston, VA  20190

PL/SQL procedure successfully completed.



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.Declare the record data type
5.Load a row in table to record type
6.A record is populated using a SELECT statement
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