GJC Technical Home Page
Index
About ODBC
Installing ODBC
Interacting with the data
ODBC Syntax
Macros


GJC Technical Home Page


GJC Technical Home Page

Integrating ODBC with WordPerfect for Windows




Basic ODBC Macro

The basic interaction with ODBC establishes the data source and the format for the returned data. You pass the data request to ODBC in the form of an SQL statement. Note that SELECT is the only SQL statement that returns data to WordPerfect and so is the only SQL statement where the choice of data format is significant. However, WordPerfect is likely to return an error if you do not give a value for ImportSetDestination().
Examples.




Inserting Data

WordPerfect can only pass data to the ODBC data source one record at a time. The basic syntax for this is:
INSERT INTO table(fieldlist) VALUES (valuelist)
You can enter this directly into the Import Data dialog box in WordPerfect. However, if you wish to repeatedly perform this operation, it is better to write a macro for the purpose. The sample macro creates a dialog box with a field corresponding to each field in the data table. I've used DIALOGDEFINE because this gives something that you can easily paste from a web page to WordPerfect.
Example




Batch Loading from WP Table

You can process a WordPerfect table, loading its data rows into a corresponding table in the ODBC data source. The concept involved is quite simple, however, you usually require a fairly long macro. The example macro is about 250 lines long.
Example




Retrieving the data

Now that you can create a database structure and populate its tables, you will want to make some use of the data. You invariably use a SELECT SQL statement for this purpose. You can make ad-hoc queries by typing the SELECT statement directly into the Import Data dialog box, e.g.
	SELECT DISTINCT
	    FirstName, LastName, Street,
	    Address1, Address2, City, PostCode
	FROM
	    Contact
	WHERE
	    Country = "UK"
returns all those contacts who are residents of UK.

Creating macros to retrieve the data is beneficial if you wish to execute a particular query many times, e.g. you regularly retrieve the data as a mailing list. The example macro creates a dialog box allowing the user to select any combination of Last Name, City, or Country. You can, of course, modify this to allow even more choice.
Example



Index | About ODBC | Installing ODBC | Interacting with the data | SQL Syntax | Macros

© 1997 – GJC Technical Ltd.

Last updated on 21 June 1997


Please email any comments about this site to webmaster@gjctech.co.uk.