Contents IndexODBC C language programming Chapter 37.  The WSQL DDE Server

User's Guide
   Part V. The SQL Anywhere Programming Interfaces
     Chapter 36. ODBC Programming
      ODBC programming for the Macintosh

When the Macintosh version of SQL Anywhere becomes available, developers of client applications other than PowerBuilder applications should follow the guideline in this section. Failure to do so could have severe effects on performance.

You should define a callback function to be used by the SQL Anywhere ODBC driver when it encounters an event it does not know how to handle. This callback function is particularly important if an update event gets into the application's queue. If this update event is not explicitly handled, and hence remains in the queue, the interprocess communication between the SQL Anywhere ODBC driver and the engine or client slows down dramatically, because of the high priority assigned to update events by the Macintosh operating system.

To define the callback function, you should include the provided C language header file EVENTCB.H. This header file has the following contents:

     #define WSQL_OPT_REGISTER_CALLBACK_EVENTS    1900
     typedef void pascal    (MAC_EVENT_CALLBACK)( EventRecord * theEvent );
     typedef MAC_EVENT_CALLBACK *    MAC_EVENT_CALLBACK_PTR;

You should define the callback function as follows (the name may be changed).

     #include "eventcb.h"
     static void pascal EventHandler( EventRecord * theEvent )
     {
         switch( theEvent->what ) {
             // The usual event processing goes here.
             // MUST process updateEvt fully, even if
             // just discarding as shown here.
             case updateEvt:
                 BeginUpdate( (WindowPtr) theEvent->message );
                 EndUpdate( (WindowPtr) theEvent->message );
                 break;
         }
     }

Other events may also be handled; updateEvt must be handled to avoid performance degradation.

The following fragment illustrates how to use the callback function.

     extern void main()
     {
         // ...
         SQLAllocConnect( env, &connection );
             // normal connection stuff
             SQLSetConnectOption( connection,
         WSQL_OPT_REGISTER_CALLBACK_EVENTS,
             (UDWORD) EventHandler );
         // ...
     }

Contents IndexODBC C language programming Chapter 37.  The WSQL DDE Server