home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / bde / sdkqry.pak / QUERY.TXT < prev    next >
Encoding:
Text File  |  1997-07-24  |  2.3 KB  |  47 lines

  1.                      QUERY.TXT for Borland Database Engine
  2.                             "QUERY" SQL/QBE example
  3.                    Copyright (c) 1994, Borland International
  4.  
  5. =====================================================================
  6.  
  7. The QUERY BDE sample application illustrates the power and flexibility
  8. of the BDE DbiQExec() function.  It also provides a convenient way to
  9. test and run SQL or QBE queries.  Working queries can be stored to
  10. disk and retrieved for later use.
  11.  
  12. Another IDAPI feature that the QUERY example highlights is its ability
  13. to do cross-database joins.  To see how this works, make sure that you
  14. have a server database connection established.  Set up an alias to a
  15. server using IDAPICFG.  Then in the Connection dialog box within
  16. QUERY, select that alias, enter your password, and press "Connect".
  17. If you are successful, you'll see "Connection Is Available"; if not,
  18. you'll see an error message which will help you troubleshoot your
  19. connection.
  20.  
  21. Once you've established a server connection in addition to the default
  22. connection, make sure the "<Default>" connection appears in the
  23. "Selected Connection" frame in the Connection dialog box and press OK.
  24. Using the default connection, a handle to a standard database, means
  25. that local SQL will be used, and local SQL is needed to do
  26. cross-database joins (this only applies to queries using the SQL
  27. language).
  28.  
  29. Once this is done, you can do a cross-database join by explicitly
  30. specifying the remote database alias as part of the tablename for the
  31. remote tables.  The syntax is similar to the syntax used to specify
  32. aliases within Paradox for Windows (i.e. ":ALIASNAME:TABLENAME").
  33. For example, let's say you have a local CUSTOMERS table (Paradox or
  34. dBASE file) and an alias, "MYSERVER", to a server database on which
  35. there is a table called CITIES.  The following cross-database join
  36. extracts all the records where the cities match.
  37.  
  38.     "select *
  39.     from customer c, :MYSERVER:CITIES s
  40.     where c.City = s.CITY"
  41.  
  42. Conversely, if you don't want to use local SQL but want an SQL query
  43. statement passed directly on to the server, make sure that the alias,
  44. "MyServer" is specified as the Selected Connection inside the
  45. Connection dialog box and press OK.  Then instead of the syntax
  46. "Select * from :MYSEVER:cities" you can use "Select * from cities".
  47.