SQL devices are configured and used in a slightly different way than other types of devices.
To configure an SQLdevice:
{date,10}{day,15}{month,20}{year,4}
When configured, the device can be associated with SCADA elements, or used in Cicode. SQL devices are used in Cicode in a slightly different way to other types of devices. For example, the order of DevSetField and DevAppend is different with SQL devices.
The following example makes a connection to a SQL device, cleans the records, adds new records to the device, finds records matching the condition, then closes the connection:
FUNCTION
DataSQLDeviceLogging()
STRING strValue = "";
INT hConnection = DevOpen("mySQLDevice") // open the device
IF hConnection <> -1 THEN
DevZap(hConnection); //clean the records
DevSetField(hConnection, "date_","30-03-2011");
DevSetField(hConnection, "day_","Wednesday");
DevSetField(hConnection, "month_","March");
DevSetField(hConnection, "year_","2011");
DevAppend(hConnection);
DevSetField(hConnection, "date_","31-03-2011");
DevSetField(hConnection, "day_","Thursday");
DevSetField(hConnection, "month_","March");
DevSetField(hConnection, "year_","2011");
DevAppend(hConnection);
DevSetField(hConnection, "date_","01-04-2011");
DevSetField(hConnection, "day_","Friday");
DevSetField(hConnection, "month_","April");
DevSetField(hConnection, "year_","2011");
DevAppend(hConnection);
DevSetField(hConnection, "date_","02-04-2011");
DevSetField(hConnection, "day_","Saturday");
DevSetField(hConnection, "month_","April");
DevSetField(hConnection, "year_","2011");
DevAppend(hConnection);
IF DevFind(hConnection, "April", "month_") = 0 THEN
strValue = StrTrim(DevGetField(hConnection, "day_"));
END;
DevClose(hConnection); //close the connection
END;
END
Published June 2018