- Table of Contents -

  1. What does the ODBC Interface do?
  2. How do I use the ODBC Interface
  3. A simple example program
  4. Download a more complete example
  5. Notes and Caveats on using the interface
  6. Technical Details

What does the ODBC Interface do?

This function call allows a developer to issue a SQL query against an ODBC data source and have the resulting rows asserted as facts into a CLIPS program. It works with the CLIPS DLL and is meant for people who would like to embed CLIPS into a C++ program using the wrapper classes.

Go to Table of Contents


How do I use the ODBC Interface

This is the function prototype for the ODBC interface :
int CCLIPSWrap::CLIPSODBCQuery(CString& strQuery,
                               CString& strCredentials,
                               CString& strDeftemplateName,
                               BOOL bImplode)

The parameters for the ODBC interface are :

Go to Table of Contents


Notes and Caveats on using the interface

There are several details to keep in mind to use the CLIPS/ODBC interface properly :

Go to Table of Contents


Technical Details

The solution was implemented by creating a new class, CVarRecordSet as an extension of CRecordset. Two functions were overridden to obtain the column names and actual data returned from a given query.
  1. PreBindFields() - This function is called by the CRecordset::Open() function after the query has executed but before any data is fetched. By calling ::SQLDescribeCol() the column names are captured and stored for use as slot names in a deftemplate.
  2. Move() - CRecordset::Move() is called initially to handle cursor movement, EOF/BOF processing etc. ::SQLGetData() is then invoked and the actual data is stored in CString format.
A fact is formatted, the function CCLIPSWRAP::CLIPSAssert() is invoked and the corresponding rules fire.

Information regarding CVarRecordset was obtained from book Visual C++ 4, Masterclass (chapter 7 by Ken Ramirez) available from Wrox Press. Note : The code provided provided in this book is compatible with VC++ 4.0. There is a version for VC++ 4.2/5.0 available in the CLIPS Wrapper Class

Go to Table of Contents


Last modified : 9-Aug-2003
Michael Giordano