Debugging Your ODBC Application

Top  Previous  Next


When you use the ODBC Accelerator Driver, the ODBC Administrator can create a log file documenting all calls made by the ODBC Accelerator Driver. It includes the actual SQL statements made by the ODBC driver to the data source, and includes any errors posted. This administrator logging slows down your program considerably, so it should only be activated during testing. Additionally, the log file can grow to large proportions very quickly, so you should turn logging off and delete the log file after using it.

Besides "snooping" on the actual SQL statements generated by the driver, you can zero in on any errors. For example, if the application is unable to connect, you can open the log file, scroll to the bottom of the file, then work up until you find the word "SQLError."

See Microsoft's ODBC documentation (ODBCINST.HLP--ODBC Options Dialog Box) for instructions on using the ODBC Administrator logs.

Logging Driver I/O for debugging

Top  Previous  Next

All of the SQL Accelerator drivers (and ISAM drivers as well) can create a log file of the Clarion File I/O statements being issued, the corresponding SQL statements, and the SQL return codes.

You can generate system-wide logs and on-demand logs (conditional logging based on your program logic via property syntax).

Activating Driver Logging

Clarion provides the Trace.EXE utility program, along with the source code in the
Trace.App file. You can run this from the Clarion Program group located in the the Start Menu. The source code Trace.App is installed in the \Examples\DriverTrace folder. This utility allows you to activate tracing options for any FILE driver and for the View engine.

These tracing options are stored in WIN.INI.

For system-wide logging, you can add the following to your WIN.INI file:







where driver is the database driver name (for example [CWTopSpeed]). Neither the INI section name [CWdriver] nor the INI entry names are case sensitive.

Profile=1 (PROP:Profile) tells the driver to include the Clarion I/O statements in the log file; Profile=0 tells the driver to omit Clarion I/O statements. The Profile switch must be turned on for the Details switch to have any effect.

Details=1 (PROP:Details) tells the driver to include record buffer contents in the log file; however, if the file is encrypted, you must turn on both the Details switch and the ALLOWDETAILS switch to log record buffer contents (see ALLOWDETAILS). Details=0 tells the driver to omit record buffer contents. The Profile switch must be turned on for the Details switch to have any effect.

Trace=1 tells the driver to include all calls to the back-end file system, including the generated SQL statements and their return codes, in the log file. Trace=0 omits these calls. The Trace switch generally generates log information that helps to debug the SQL drivers, but is normally not particularly useful to the developer.

TraceFile names the log file to write to. If TraceFile is omitted the driver writes the log to driver.log in the current directory. Pathname is the full pathname or the filename of the log file to write. If no path is specified, the driver writes the specified file to the current directory.

To view the trace details in your system debugger, name the target trace file DEBUG:.

Logging opens the named logfile for exclusive access. If the file exists, the new log data is appended to the file.

On Demand Logging

For on-demand logging you can use property syntax within your program to conditionally turn various levels of logging on and off. The logging is effective for the target table and any view for which the target table is the primary table.

file{PROP:Profile}=Pathname   !Turns Clarion I/O logging on

file{PROP:Profile}=''         !Turns Clarion I/O logging off

PathName = file{PROP:Profile} !Queries the name of the log file

file{PROP:Log}=string         !Writes the string to the log file

file{PROP:Details}=1          !Turns Record Buffer logging on

fFile{PROP:Details}=0         !Turns Record Buffer logging off

where Pathname is the full pathname or the filename of the log file to create. If you do not specify a path, the driver writes the log file to the current directory.

You can also accomplish on demand logging with a SEND() command and the LOGFILE driver string. See LOGFILE for more information.

Language Level Error Checking

You can use the FILEERROR() and FILEERRORCODE() functions to capture messages and codes returned from the backend server to the SQL Accelerator driver. See the Language Reference for more information on these functions.

See Also: