This script gets the last 16 records from ODBC database. WebDATA is an ODBC DSN to an Access Database on SCADA Node.
# initialize an array
array set Array1 [list 4 x 5 x 6 x 7 x 8 x 9 x 10 x 11 x \
12 x \
13 x \
14 x \
15 x \
16 x]
SQLDIRECT "CONNECT SESSION 3 TO WebDATA"
SQLDIRECT "USE SESSION 3"
# DECLARE A POINTER TO NEWEST DATA JUST ENTERED
SQLPREPARE "DECLARE C3 CURSOR FOR "
SQLPREPARE "SELECT * FROM Table1 "
SQLPREPARE "WHERE Date='[GETVAL %TTMDATE]' "
SQLPREPARE "ORDER BY Time DESC"
SQLEXECUTE
SQLDIRECT "OPEN C3"
for {set Z 4} {$Z<=16} {incr Z} {
SQLDIRECT "FETCH NEXT C3 INTO text1, text2, text3, text4"
set str1 "[GETVAL text1] [GETVAL text2] [format %9.1f [GETVAL text3]] [format %7.1f[GETVAL text4]] [GETVAL text5]"
array set Array1 [list $Z $str1]
}
SQLDIRECT "CLOSE C3"
SQLDIRECT "DISCONNECT SESSION 3"
SETVAL text=$Array1(4)
SETVAL text5=$Array1(5)
SETVAL text6=$Array1(6)
SETVAL text7=$Array1(7)
SETVAL text8=$Array1(8)
SETVAL text9=$Array1(9)
SETVAL text10=$Array1(10)
SETVAL text11=$Array1(11)
SETVAL text12=$Array1(12)
SETVAL text13=$Array1(13)
SETVAL text14=$Array1(14)
SETVAL text50=$Array1(15)
SETVAL text70=$Array1(16)