Table Expression in FROM Clause
When a class is added to a query, the generated SQL includes the associated table for the class in the FROM clause of the query. It is also possible to append a TableExpression to the FROM clause as shown below: appendFrom( TableExpression a_tableExpression )
The following are concrete TableExpression implementations:
ClassTableExpression
This class represents a class specification of a table that can be used in a SQL FROM clause. Introspection information is used to determine the associated table.
ClassViewExpression
This class represents a "view" of a class table that can be used in a SQL FROM clause. All descendent classes are part of this view (however, no additional sub-class columns are included). This class is useful for queries involving outer joins or group by because all sub-classes are treated as a single "table".
SubSelectExpression
This class represents a subselect that can be used in a SQL statement. The subselect is specified via a StatementSpec attribute.
ExternalTableExpression
This class represents a table that can be used in a SQL FROM clause. The exact table name specified is used directly in the SQL statement.
The following example builds a query against a non-modeled table named dual:
QuerySpec qs = new QuerySpec();
int fromIndex = qs.appendFrom(new
ExternalTableExpression("dual"));
TableColumn dummyColumn = new TableColumn("dual", "dummy");
SQLFunction currentDate = SQLFunction.new
SQLFunction(SQLFunction.SYSDATE);
qs.appendSelect(dummyColumn, new int[] { fromIndex }, false);
qs.appendSelect(currentDate, null, false);
這是否有幫助?