Applies To: |
|
Summary: |
What options are available to me if I want to log alarms and reports to my SQL database? What if I also want to read data from my database back into Citect? |
Solution: |
Basically there are three ways to exchange
data to an external SQL database such as MS Access or Oracle.
Method 1. The format and locations of each of your SQL databases are defined through Citects Devices records. This will specify: the format of the database (ie the field names and widths); the Header which is the database connection string for ODBC connection (eg DSN=SybaseDatabase); the database table name etc. Note 1: All database fields are character(string) field types; Note 2: The field names defined here must be identical to the field names defined in the referenced SQL database table. Note 3: It is advisable to specify field lengths. (If they aren't identical you may loose data) Note 4: If logging Alarms directly to an SQL device, you cannot log the Alarm "Desc" field. If you do, the SQL INSERT statement generated by Citect will contain the word "Desc" (a reserved SQL word meaning "Descending") which will result in a syntactical error. Method 2. To use an SQL device in Citect, you can only use a subset of the Cicode Device functions- namely: DevControl(), DevOpen(), DevClose(), DevFind() DevGetField() and DevWrite(). So you cannot actually modify the device definition in runtime. To write Citect data to an SQL database, you can use the DevWrite() function (DevWrite automatically adds a new record - you can't modify an existing record) to write to all fields in the new record. No data is written to the database if you do not write to all fields. To delete records from an SQL database you must use the Cicode SQL functions described below. Method 3. Notes:
Related Articles Q2034 |
Keywords: |
Related Links
Attachments