This block shows legal and illegal record assignments. : Record Data Type « PL SQL « Oracle PL / SQL






This block shows legal and illegal record assignments.

  
SQL>
SQL> DECLARE
  2    TYPE t_Rec1Type IS RECORD (
  3      Field1 NUMBER,
  4      Field2 VARCHAR2(5));
  5    TYPE t_Rec2Type IS RECORD (
  6      Field1 NUMBER,
  7      Field2 VARCHAR2(5));
  8    v_Rec1 t_Rec1Type;
  9    v_Rec2 t_Rec2Type;
 10  BEGIN
 11    v_Rec1 := v_Rec2;
 12
 13    v_Rec1.Field1 := v_Rec2.Field1;
 14    v_Rec2.Field2 := v_Rec2.Field2;
 15  END;
 16  /
  v_Rec1 := v_Rec2;
            *
ERROR at line 11:
ORA-06550: line 11, column 13:
PLS-00382: expression is of wrong type
ORA-06550: line 11, column 3:
PL/SQL: Statement ignored


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.Declare the record data type
5.Load a row in table to record type
6.A record is populated using a SELECT statement
7.declare record with not null attribute
8.Assign a wrong record type
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