Referencing row variables

Row variable values can be referenced by name wherever row variable data type references are supported.

Supported row variable reference contexts include the following:
  • Source or target of a SET statement
  • INSERT statement
  • Target of SELECT INTO, VALUES INTO, or FETCH statements
The following is an example of a row variable being assigned to another row variable with the same definition using the SET statement:
  -- Referencing row variables as source and 
     target of a SET statement
  SET v1 = v2;
The following is an example of row variables being referenced in an INSERT statement that inserts two rows. The row variables v1 and v2 have a field definition that is type compatible with the column definition of the table that is the target of the INSERT statement:
  -- Referencing row variables in an INSERT statement
  INSERT INTO employee VALUES v1, v2;
The following is an example of a row variable being referenced in a FETCH statement. The row variable empRow has the same column definition as the result set associated with the cursor c1:
 -- Referencing row variables in a FETCH statement
 FETCH c1 INTO empRow; 
The following is an example of a row variable named v3 being referenced in a SELECT statement. Two column values in the employee table are being selected into the two fields of the variable v3:
 -- Referencing row variables in a SELECT statement
 SELECT id, name INTO v3 FROM employee;