Accessing a Row Variable

The TABLE keyword can make the row variable a collection-derived table. That is, a row appears as a table in an SQL statement. For a row variable, think of the collection-derived table as a table of one row, with each field of the row type being a column of the row. Use the TABLE keyword in place of the name of a table, synonym, or view in these SQL statements:
  • The FROM clause of the SELECT statement to access a field of the row variable
  • The UPDATE statement to modify an existing field in the row variable

The DELETE and INSERT statements do not support a row variable in the collection-derived-table segment.

For example, suppose an ESQL/C host variable a_row has the following declaration:
EXEC SQL BEGIN DECLARE SECTION;
   row(x int, y int, length float, width float) a_row;
EXEC SQL END DECLARE SECTION;
The following ESQL/C code fragment adds the fields in the a_row variable to the row_col column of the tab_row table:
EXEC SQL update table(:a_row)
   set x=0, y=0, length=10, width=20;
EXEC SQL update rectangles set rect = :a_row;