Method USqlStatement():createVirtualTableFromArray() Foundation

Creates a virtual table from an array.

Syntax
:createVirtualTableFromArray( <aData> [,<cAlias>] ) --> cAlias
Parameters
<aData>
An array of objects or a two-dimensional array.
<cAlias>
An alias name used to identify the virtual table.
Return

The method returns the alias name for the virtual table.

Description

The method :createVirtualTableFromArray() creates a virtual table from a given array and associates the table with the specified alias name. By using the alias name in the FROM clause of any SQL statement, the virtual table can be accessed via SQL.

The created virtual table is a projection of the data in the array, not a copy. When using an array of objects, only the exported instance members become visible as a column in the virtual table. In the case of a two-dimensional array, the first dimension specifies the row, and the fields are defined in the second dimension. Since an array has an index instead of a name, the columns in the virtual table are named field1, field2 and so forth. Use the SQL <column> AS <new-name> syntax in the projection of a query to give the columns proper names in the result set.

This method raises a runtime error in case the data passed is not an array or if the array is empty. In both cases, there is no way to define a data model for the virtual table. A runtime error is also created if the virtual table creation fails.

Note that a virtual table is read-only. Consequently, INSERT/DELETE/REPLACE or ALTER statements are not supported.

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.