CustomSQLFrom (Method)

Applies To:

QuerySection object

Description:

Sets the FROM clause of a SQL statement before processing.

The FROM clause indicates which tables are to be referenced when the SELECT statement is processed.

The FROM clause is appended to your custom SQL each time the CustomSQLFrom method is activated. To clear any clauses appended to the Custom SQL statement, use the ResetCustomSQL (Method).

CustomSQLFrom (Method), CustomSQLWhere (Method), and ResetCustomSQL (Method) correspond to the edit SQL functionality in the Custom SQL dialog box.

Note:

To use the Custom SQL feature, the query data model must have at least one table. If no table exists, then the Console Window displays this message: “Script(x):uncaught exception:Invalid String”.

Note:

You can use the CustomSQLFrom (Method) to define all of the SQL (including the WHERE clause) in the Custom SQL window. If a query includes temporary tables and correlated subqueries, it is recommended that you use CustomSQLFrom method to define all of the SQL.

Syntax:

Expression.CustomSQLFrom(String CustomSQLStr)

Expression Required:

An expression that returns a query object

Example:

This example sets the FROM clause and the WHERE clause, next processes the query and then restores the original SQL statement:

//Set the FROM clause, Set the WHERE clause, and PROCESS, and then RESET SQL
ActiveDocument.Sections["Query"].CustomSQLFrom(‘FROM From.Sales_Fact, From.Periods, From.Products’) 
ActiveDocument.Sections["Query"].CustomSQLWhere(‘WHERE (Periods.Day_Id=Sales_Fact.Day_Id AND Products.Product_Id=Sales_Fact.Product_Id)  AND (Periods.Quarter='Q1')’)
ActiveDocument.Sections["Query"].Process()
ActiveDocument.Sections["Query"].ResetCustomSQL();