Oracle PL/SQL - %ROWTYPE Attribute and Virtual Columns

Introduction

If you use the %ROWTYPE attribute to define a record variable that represents a full row of a table with a virtual column, you cannot insert that record into the table.

You must insert the individual record fields into the table, excluding the virtual column.

The following code inserts the individual record fields into the table, excluding the virtual column.

Demo

SQL>
SQL>-- from  w w  w .  j a  v  a 2s .c  om
SQL> DECLARE
  2    dep_rec dept%rowtype;
  3  BEGIN
  4    dep_rec.destination := 'X';
  5    dep_rec.departure_time := SYSDATE;
  6    dep_rec.delay := 1500;
  7
  8    INSERT INTO dept (destination, departure_time, delay)VALUES
  9      (dep_rec.destination, dep_rec.departure_time, dep_rec.delay);
 10  end;
 11  /

SQL>

Related Topic