Citect SQL Table Control

Patient

Member
Join Date
Jun 2012
Location
Auckland
Posts
50
I'm a bit new to Citect and SQL. Having trouble using the SQL Table Control. I can get a table but when I want to retrieve data from the table using the command LibTable_GetCellValue(sName,row,col); it returns a null string.



I used SetCellValue and was then able to read the value back using the same command but I can't seem to get values from my initial table. I feel like I'm missing a step.



Anyone else used this feature?
 
I see this is an older thread, however when searching online for any assistance with using the SQLTable library controls (or even the AlarmTable controls recently for that matter) the help was non-existent other than outlining the fields on the dialog.

I may have misinterpreted what your issue is, however I have successfully used the SQLTable control to display and update from a remote database - in this case a custom table created within the same database running the Citect Historian tables.

To load the data I used the LibSqlTable_ReloadData function. It seem that there was a limitation on the length of the SQL Select Query field which didn't allow for the query I wanted, so I used the database to create a stored procedure and then called the "EXEC" command within the cicode (which would be in the [Query_String] part below). This was achieved with a simple Cicode function called from the Initialize property. My function was:

INT FUNCTION SQLTableSetQuery([Any arguments required])

STRING sRecordSource;
STRING sConnection;

//Set the initial query of the table to execute the query
LibSqlTable_SetProperty([SQLTable_Name], "Select", [Query_String])

//Get the SELECT statement and the Connection STRING and Reload the table data
sRecordSource = LibSqlTable_GetProperty([SQLTable_Name], "Select");
sConnection = LibSqlTable_GetProperty([SQLTable_Name], "Connection");
LibSqlTable_ReloadData([SQLTable_Name], sRecordSource , sConnection);

RETURN 1;​

END

The purpose of the table for me was to have an operator input a particular manual reading and then press a button on screen to write the manual value, and compared Citect variable tag value, to the custom table. The writing of the values the database was performed with some simple SQL Cicode functions abbreviated here:

hSQL = SQLConnect([Connection_String]);
IF hSQL <> -1 THEN
sQuery = [SQL_INSERT_Query];
SQLExec(hSQL, sQuery);​
END
SQLDisconnect(hSQL);

Following this, to reload the table instantly, I used the same functions as in the previous Cicode function above:

//Get the SELECT statement and the Connection STRING and Reload the table data
sRecordSource = LibSqlTable_GetProperty([SQLTable_Name], "Select");
sConnection = LibSqlTable_GetProperty([SQLTable_Name], "Connection");
LibSqlTable_ReloadData([SQLTable_Name], sRecordSource , sConnection);

From the initial post, it seems that the cicode functions trying to be used (LibTable_GetCellValue/LibTable_SetCellValue) are not actually manipulating an SQL table as the intention of the library control would be.

Hope this helps someone!
 

Similar Topics

Hello all! I am new in Citect SCADA. I need to create material tracking system in which I have a dozen of photometric sensors. When each sensor...
Replies
1
Views
2,983
Hello Everyone I working in power plant and we using citect 7.20 , how we can connect citect to mysql to show some system info on website or...
Replies
1
Views
1,482
hi. I want to connect to sql server and i get data from it and i show it on textbox in citect scada 2018.i have this code for this task.data...
Replies
1
Views
1,608
hi. I want to connect to sql server and i get data from it and i show it on textbox in citect scada 2018.i have this code for this task.data...
Replies
17
Views
5,412
Hi all, I have a Citect SCADA V 5.21 and MySQL 0.9.4 beta installed on my Server (Windows Server 2003). All process events are logging in a data...
Replies
19
Views
4,737
Back
Top Bottom