When you use the collection-expression format, certain restrictions apply:
To perform insert, update, and delete operations, you must use the collection-variable format.
For example, the following statement returns an error because the collection-derived table, TABLE (parents.children), refers to the table parents, which is also referenced in the FROM clause:
SELECT COUNT(*) FROM parents, TABLE(parents.children) c_table WHERE parents.id = 1001
To counter this restriction, you might write a query that contains a subquery in the Projection clause:
SELECT (SELECT COUNT(*) FROM TABLE(parents.children) c_table) FROM parents WHERE parents.id = 1001
In addition to the previously described restrictions, the following restrictions also apply when you use the collection-expression format with ESQL/C:
The data type of the underlying collection variable must be determined statically. To counter this restriction, you can explicitly cast the variable to a typed collection data type (SET, MULTISET, or LIST) that the database server recognizes. For example,
TABLE(CAST(? AS type))
To counter this restriction, you must explicitly cast the variable to a typed collection data type (SET, MULTISET, or LIST) that the database server recognizes. For example,
TABLE(CAST(:hostvar AS type))