Tutorial: Using xfodbcusr.c as an example

This tutorial guides you through the steps needed to create user-defined data routines. As you follow the tutorial, you’ll modify xfodbcusr.c to include routines that do the following:

Once you’ve modified the code in xfodbcusr.c, you’ll compile and link the modified file as xfodbcusr.dll (Windows), XFODBCUSR.so (Unix), or xfodbcusr_so.exe (OpenVMS). You can then watch it work as you use xfODBC to read and write data to the sample database supplied with the xfODBC installation.

Note that these routines are designed to work only with the sample database that’s included with the xfODBC installation. Like all user-defined data routines, they can’t change the size of a field, only the contents.

1. Open Repository and do the following:

For help with any of the tasks in this step, see the Repository User’s Guide.

2. Run dbcreate with the -x or -c option (overwrite or create). Either option will work. For information on dbcreate options, see dbcreate utility.
3. Open xfodbcusr.c in a text editor. (You’ll find this file in the connect\synodbc\user subdirectory of the main Synergy/DE installation directory.) Remove or comment out the #ifdef and #endif lines from all four of the functions: user_to_alpha(), user_to_number(), alpha_to_user(), and number_to_user(). For client/server configurations, uncomment the section for your host machine’s operating system. Save your changes and close the file.
4. Run one of the following (located in the connect\synodbc\user subdirectory of the main Synergy/DE installation directory):

These files compile xfodbcusr.c, link it, and save it as one of the following:

To compile and link using Microsoft Visual Studio, create a new DLL, add xfodbcusr.c, and then build.

5. Copy the DLL, shared library, or shared image you just created to the connect subdirectory of the main Synergy/DE installation directory. This will overwrite the file of the same name that’s already there. For client/server configurations, copy the file to the connect subdirectory of the main Synergy/DE installation directory on the server.
Note

On OpenVMS, the XFODBCUSR_SO logical must be set to the path and filename of the xfodbcusr_so.exe shared image. See Other environment variables used by xfODBC for more information.

6. Start an ODBC-enabled application, and access the data in the sample database. (For help with this step, see Accessing a Synergy Database.) Note the following:
7. To verify that addresses are converted to mixed-case characters as they’re input and all uppercase characters as they’re retrieved by an application, do the following:
8. To verify that dates are stored as the fifteenth of the month and display as the first of the month when retrieved, do the following:
9. To verify that customer limits for Oregon customers are stored as $2000.75 and that $200.00 is added when they’re retrieved, do the following:

You can also use the following methods to debug user-defined data routines: