Using CitectSCADA > Using Devices > Formatting Data in the Device > Writing SQL records using a database device

Writing SQL records using a database device

To use an SQL device in CitectSCADA, you cannot use every the Cicode Device function; you can only use the following functions:

DevOpen()

DevClose()

DevGetField()

DevFind()

DevWrite()

DevNext()

DevSeek()

DevAppend()

DevWrite()

DevZap()

DevControl()

DevSetField()

To write CitectSCADA data to an SQL database, use the DevWrite() function, but you need to add a new record and write to fields in the new record. No data is written to the database if you do not write to all fields.

For example:

FUNCTION 
WriteRecipeData(INT hDevice, STRING sName, INT Water, INT Sugar, INT Flour, INT Salt, INT Yeast, INT Milk)
DevWrite(hDevice, sName);
DevWrite(hDevice, Water);
DevWrite(hDevice, Sugar);
DevWrite(hDevice, Flour);
DevWrite(hDevice, Salt);
DevWrite(hDevice, Yeast);
DevWrite(hDevice, Milk);
END

The following functions return error 267 (File mode is invalid) when the device type is SQL:

DevFlush()

DevPrev()

DevDelete()

The follow function returns error 263 (Cannot read file) when the device type is SQL:

DevRead()

The following functions return error -1 when the device type is SQL:

DevSize()

DevRecNo()