Automatic table referencing in SQL with TApolloQuery

<< Click to Display Table of Contents >>

Navigation:  Apollo VCL Components > Apollo VCL Component Reference > TApolloQuery >

Automatic table referencing in SQL with TApolloQuery

In previous releases, ApolloQuery required that developers explicitly specified the tables used in the query statement. This is no longer the case. The Apollo SQL engine automatically parses the tables referenced by in SQL statement.

TApolloQuery assumes the defaults set in the properties TableType, Password and OEMTranslate for all the tables referenced in the same query. In addition to automatic table parsing, you are able to apply various individual settings for each table being accessed, such is the when a query accesses a table or multiple tables that: are of mixed table types, have mixed OEM, character settings, require OEMTranslate, or are password protected.

TApolloQuery.TApolloTables property remains for backwards compatibility.

Important. If you are using TApolloQuery that already has TApolloTable items defined and your SQL statement uses additional tables, not defined in the TApolloTable item list, TApolloQuery will use the values defined in the table list directly and will not try won't try to resolve the query for additional tables.. So, if a table is defined for TApolloTable items, then all tables used in the SQL statement will need to be defined. Or delete the list and let TApolloQuery parse the table names as expected.

Another way to pass additional table information to the query engine is by adding SQL code to your SQL statement, surrounded by [* *]. This bracket- asterisk combination allows you to add table-specific information for the query engine to process. The syntax is as follows:

 

For example:

 Select * From MYDATA Where MYDATA.StateCode = "CA"

 [* TableName:MYDATA.DBF, Alias: MYDATA,

TableType: ttsxFOX, OEMTranslate: False, Password: secret *]

 

Parameters accepted between the "[* *]" are:

 

TableName

Name of the physical table, use the file extension

Alias

Name of the physical table, use the file extension

TableType

Optional. ttsxFOX, ttsxNTX, ttsxNSX or ttsxNSX_DBT or FOXPRO, CLIPPER, HIPER-SIX both syntax styles are accepted.

OEMTranslate

Optional. True or False. False by default. Used to support DOS tables

Password

Optional. If the table is encrypted.

 

The following rules apply

Not case sensitive

Quotes not allowed.

Separate each pair by commas.

At least the TableName and Alias must be provided. The other parameters are optional.

Syntax

[* TableName:Test.dbf, Alias:Test, TableType:FOXPRO, OEMTranslate:True, Password:shazam *]

 

Examples

1. For example, if you are accessing a FoxPro table, that is not password protected, and uses default Windows characters for sorting, and doesn’t require OEMTranslate, then no additional parameter will needed. The following code run without specifying paramters:

 

 Select * From Test

 

2. Ifthe Test.dbf table has a password, then you would use :

 

 Select * From Test

 [* TableName:Test.dbf, Alias:Test, Password:shazam *]

 

Alternatively, you can use the following:

 

 Select * From City, State Where City.StateCode = State.StateCode

 [* TableName:City.dbf, Alias: City | TableName:State.dbf, Alias:State *]

 

Where the "|" (pipe operator) can be used to list multiple tables.