Object: sql

Description

The sql object lets you obtain the value for a fact from a database using a SQL query. The format of the query depends upon the underlying database. Consult a user's manual for your database for details. Under Windows, the query is issued using ODBC.

For example:

id
avg_weight
path
/ health
query
Select avg(weight) from stats 
where name = '%name%'
type
integer
      
length
4


This query gets the average weight from the table 'stats' where the person's name is equal to the value of the fact 'name'. The 'name' can be derived from a user question, another sql query, a rule or a table.

The result of the query must be a single value in a single field.

Setting Up an ODBC Database

Before you can run a sql object you need to create an ODBC data source. This is done in the Windows Control Panel. Open the ODBC Administrator or Data Sources (ODBC) panel and add a new DSN that points to your database. Put the name of the ODBC Data Source in the main knowledgebase object. All the sql queries in your knowledgebase will be issued to that data source.

SQL Properties

The properties of the query are:

Property Name Description Default Value Required
id The name of this object. See Object Names for details. <none> yes
path The folder this object is located in. See Folders for details. / yes
description A text description (comment)--not used during reasoning. <none> no
query The SQL query. This may contain other object names in %'s.   yes
type The type of the value to be returned by the query: text, integer, float or date.   yes
length The maximum length of the value returned by the query.   yes




Copyright ©1995-2006 Amzi! inc. All Rights Reserved. Privacy Policy.
Amzi!, KnowledgeWright and WebLS are registered trademarks and Adventure in Prolog, Logic Server, Logic Explorer, Adventure in Prolog and Subscription Plus are trademarks of Amzi! inc.