How to connect and read data from a relational database?
There is a ctrl library "rdb.ctl" which offers you a set of functions to easily access relational databases!
The functions in the library use the CTRL functions to access external database.
For more information concerning the CTRL functions please have a look at the WinCC OA Documentation and search for "Control-ADO".
The following example shows how to connect to a defined data source in Windows systems.
1) Create an odbc data source (DSN) "mydb" in your Windows environment
2) Write the following script, e.g. on a button in a panel
#uses "CtrlADO"
#uses "rdb"
main()
{
dbConnection db;
dyn_dyn_anytype res;
rdbOpen(db, "DSN=mydb;UID=scott;PWD=tiger");
rdbSelect(db, "SELECT * FROM emp", res);
DebugTN(res);
rdbExecute(db, "UPDATE emp SET sal=sal*0.10");
rdbSelect(db, "SELECT * FROM emp", res);
DebugTN(res);
rdbClose(db);
}