The typed row variable
A typed row variable specifies a field list, which contains the name and data type of each field in the row.
EXEC SQL BEGIN DECLARE SECTION;
row (circle_vals circle_t, circle_id integer) mycircle;
row (a char(20),
b set(integer not null),
c decimal(10,2)) row2;
row (x integer,
y integer,
length integer,
width integer) myrect;
EXEC SQL END DECLARE SECTION;
- Any built-in data type (such as INTEGER, CHAR, BOOLEAN, and FLOAT) except BYTE, TEXT, SERIAL, or SERIAL8.
- Collection data types, such as SET and LIST
- Row types, named or unnamed
- Opaque data types
row (
smint_fld smallint,
char_fld char(20)
) row_var;
Use a typed row variable when you know the exact data type of the row-type column that you store in the row variable. Match the declaration of a typed row variable exactly with the data type of the row-type column. You can use this row variable directly in SQL statements such as INSERT, DELETE, or UPDATE. You can also use it in the collection-derived table clause.
EXEC SQL BEGIN DECLARE SECTION;
row (x integer, y integer) typed_row1, typed_row2;
EXEC SQL END DECLARE SECTION;
If you do not know the exact data type of the row-type column you want to access, use an untyped row variable.