An ODBC Interface for CLIPS
- Table of Contents -
- What does the ODBC Interface do?
- How do I use the ODBC Interface
- A simple example program
- Download a more complete example
- Notes and Caveats on using the interface
- Technical Details
CLIPS DLL and is meant for people who would like to embed CLIPS into a C++ program using the wrapper classes.
int CCLIPSWrap::CLIPSODBCQuery(CString& strQuery, CString& strCredentials, CString& strDeftemplateName, BOOL bImplode)
The parameters for the ODBC interface are :
- CString& strQuery - This is the SQL query
- CString& strCredentials - This is the ODBC connect string. This must contain
DSN=ODBC data source name;. It may also contain UID and password information.
- CString& strDeftemplateName - Is the name of the deftemplate where the
facts are to be asserted. All column names returned from the SQL query are
forced to lower case. Code your deftemplate accordingly.
- BOOL bImplode - If this parameter is set to TRUE, then all data fields will be imploded before the fact is asserted.
- All ODBC administrivia must be in working order.
(i.e. Drivers must be installed, ODBC data source must be registered etc.)
- All deleted records are skipped.
- If a record contains a data field with a NULL value, that field will NOT be included in the assert statement.
- A deftemplate containing all of the desired columns has to be loaded before the call to
CCLIPSWRAP::CLIPSODBC()in order to 'catch' the rows returned from query.
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.
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.
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
Last modified : 9-Aug-2003