Constructed rows are described with respect
to row variables in Constructed rows. For information
about the syntax of a constructed row, see the Constructed Row segment
in the Informix Guide to SQL:
Syntax.
A literal-row value
For more information about the syntax of
a literal-row value, see the Literal Row segment in the Informix Guide to SQL:
Syntax.
To represent literal values for a row-type column, you
specify a literal-row value. You create a literal-row value or a named
or unnamed row type, introduce the value with the ROW keyword and
provide the field values in a comma-separated list that is enclosed
in parentheses. You surround the entire literal-row value with quotes
(double or single). The following INSERT statement inserts the literal
row of ROW(0, 0, 4, 5) into the rectangle column in the tab_unmrow table
(that Sample tables with row-type columns defines):
The UPDATE statement in the following figure overwrites
the SET values that the previous INSERT added to the tab_unmrow table. Figure 1: Updating a row-type
column
EXEC SQL update tab_unmrow
set rectangle = ("row(1, 3, 4, 5)")
where area = 20;
Important: If you omit the WHERE clause, the preceding
UPDATE statement updates the rectangle column in all rows of
the tab_unmrow table.
If any character value appears in this literal-row value,
it too must be enclosed in quotes; this condition creates nested quotes.
For example, a literal value for column row1 of row type ROW(id
INTEGER, name CHAR(5), would be:
'ROW(6, "dexter")'
To specify nested quotes in an SQL statement in the Informix ESQL/C program,
you must escape every double quotation mark when it appears in a quotation
mark string. The following two INSERT statements show how to use escape
characters for inner quotes:
When you embed a double-quoted string inside another double-quoted
string, you do not need to escape the inner-most quotation marks:
EXEC SQL insert into tabx
values (1, "row(""row(12345)"")");
For more information about the syntax of literal values
for row variables, see Literal values as field values. For more information
about the syntax of literal-row values, see the Literal Row segment
in the Informix Guide to SQL:
Syntax.
If the row type contains a row type or a collection as
a member, the inner row does not need quotes. For example, for column col2 whose
data type is ROW(a INTEGER, b SET (INTEGER)), a literal value would
be: