New in the Community? Get started here

Schneider Electric Exchange Community

Discuss and solve problems in energy management and automation. Join conversations and share insights on products and solutions. Co-innovate and collaborate with a global network of peers.

Register Now
Geo SCADA Expert Forum
Make the most of your remote operations with end-to-end solutions with Process Automation’s SCADA and Telemetry Solutions. With the challenges that remote sites present, reliable communications for remote operation, monitoring & management are vital in enhancing productivity and ensuring profitability.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Sisko

[Imported] SQL Commands to extract rows from Data Table in ST

>>Message imported from previous forum - Category:Scripts and Tips<<
User: hemanth, originally posted: 2019-10-08 11:28:11 Id:534
Hi,
I have created a data table [TEST1_TABLE] in clearscada with Index1,val1,val2 all INT type.
Inserted few rows using INSERT command.
Is it possible to extract number of rows to an internal variable in ST to perform some calculation! I have been trying the following code to extract rows from DataTable but not successful in transferring to internal variables [ Rec_count,val1,val2]
IS TEHRE A WAY TO GET ROWS?

TYPE Records:
STRUCT
Index1:INT;
val1:INT;
val2:INT;
END_STRUCT;
END_TYPE

PROGRAM SQL_EXTRACT
VAR
pump1data :Records;
END_VAR;

VAR
Rec_count :INT;
val1 :INT;
val2 :INT;
END_VAR;

VAR

Test1 AT %S(Select Index1,val1,val2 FROM TEST1_TABLE WHERE Index1 = 2):RESULTSET OF RECORDS;
END_VAR;

IF Test1.Valid = TRUE THEN

Rec_count := pump1data.Index1;
val1 := pump1data.val1;
val2 := pump1data.val2;

END_IF;

END_PROGRAM

 

 

1 REPLY 1
Sisko

Re: [Imported] SQL Commands to extract rows from Data Table in ST

>>Responses imported from previous forum


Reply From User: geoffpatton, posted: 2019-10-08 20:41:59
I think it is Test1.Size is the number of rows


Reply From User: hemanth, posted: 2019-10-10 03:54:32
Thanks..
following link provides more info...
https://www.citect.schneider-electric.com/scada/clearscada/help/2017/Content/LogicGuide/UsinganSTPro...