Statit Support Articles
Administration
Frequently Asked Questions
How-to
ODBC
Sample Code
 
Quality Practice Tips

Subscribe to Statit Bulletin, our quarterly SPC/Quality Resource e-newsletter

Your Name:
E-mail:
Company:
Industry: Healthcare
Manufacturing
 

Statit & ODBC: What to Watch for in SQL Queries


Abstract: General information about how the ODBC mechanism works in Statit 5.x.

Products: Statit e-QC, Statit e-Server, Statit Custom QC

Dates:

Dates and Datestamps typically need to be in the form of

{ts 'YYYY-MM-DD HH:MM:SS'}
Beginsql
  SELECT
   Box_Inspection_Data.Box_Insp_ID,
   Box_Inspection_Data.Part_name,
   Box_Inspection_Data.Operation,
   Box_Inspection_Data.Machine,
   Box_Inspection_Data.Parameter,
   Box_Inspection_Data.Pass_Fail,
   Box_Inspection_Data.No_Fail,
   Box_Inspection_Data.DStamp,
   Box_Inspection_Data.Operator_ID,
   Box_Inspection_Data.Inspector_ID,
   Box_Inspection_Data.Batch_ID,
   Box_Inspection_Data.Phase,
   Box_Inspection_Data.Process_Note,
   Box_Inspection_Data.Assignable_Cause
  FROM
   Box_Inspection_Data
  WHERE
   Box_Inspection_Data.DStamp = {ts '2006-07-12 00:00:00'}
endsql

This is not always true in that modern databases have functions such as TO_DATE to convert strings to dates within the query.

Strings:

Strings in a query are surrounded by single quotes:

Beginsql
 SELECT
   Box_Inspection_Data.Box_Insp_ID,
   Box_Inspection_Data.Part_name,
   Box_Inspection_Data.Operation,
   Box_Inspection_Data.Machine,
   Box_Inspection_Data.Parameter,
   Box_Inspection_Data.Pass_Fail,
   Box_Inspection_Data.No_Fail,
   Box_Inspection_Data.DStamp,
   Box_Inspection_Data.Operator_ID,
   Box_Inspection_Data.Inspector_ID,
   Box_Inspection_Data.Batch_ID,
   Box_Inspection_Data.Phase,
   Box_Inspection_Data.Process_Note,
   Box_Inspection_Data.Assignable_Cause
 FROM
   Box_Inspection_Data
 WHERE
   Box_Inspection_Data.Part_name = 'Gold 45'
endsql


Operators:

You may get an error if you use => instead of >= for greater-than-equal-to, or =< instead of <=. Place the symbols as you would say it.

If you would like additional information, please call our Support staff at (541) 752-4100 or send email to .