QUERY.TXT for Borland Database Engine "QUERY" SQL/QBE example Copyright (c) 1994, Borland International ===================================================================== The QUERY BDE sample application illustrates the power and flexibility of the BDE DbiQExec() function. It also provides a convenient way to test and run SQL or QBE queries. Working queries can be stored to disk and retrieved for later use. Another IDAPI feature that the QUERY example highlights is its ability to do cross-database joins. To see how this works, make sure that you have a server database connection established. Set up an alias to a server using IDAPICFG. Then in the Connection dialog box within QUERY, select that alias, enter your password, and press "Connect". If you are successful, you'll see "Connection Is Available"; if not, you'll see an error message which will help you troubleshoot your connection. Once you've established a server connection in addition to the default connection, make sure the "" connection appears in the "Selected Connection" frame in the Connection dialog box and press OK. Using the default connection, a handle to a standard database, means that local SQL will be used, and local SQL is needed to do cross-database joins (this only applies to queries using the SQL language). Once this is done, you can do a cross-database join by explicitly specifying the remote database alias as part of the tablename for the remote tables. The syntax is similar to the syntax used to specify aliases within Paradox for Windows (i.e. ":ALIASNAME:TABLENAME"). For example, let's say you have a local CUSTOMERS table (Paradox or dBASE file) and an alias, "MYSERVER", to a server database on which there is a table called CITIES. The following cross-database join extracts all the records where the cities match. "select * from customer c, :MYSERVER:CITIES s where c.City = s.CITY" Conversely, if you don't want to use local SQL but want an SQL query statement passed directly on to the server, make sure that the alias, "MyServer" is specified as the Selected Connection inside the Connection dialog box and press OK. Then instead of the syntax "Select * from :MYSEVER:cities" you can use "Select * from cities".