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);
}

Date added:
Last revised:
Hits:
11.269
Version:
3.8, 3.9, 3.10, 3.11
Platform:
Windows
Rating:
Rating: 3.2. 99 vote(s).
99 anonymous votes
No rating done at all.
Your vote was '' (0 of 5) You are an anonymous user.
You may log on to do personalized votings
Click the rating bar to rate this item Please log on to do ratings
  • Notification

    FE user cannot be identified! (1403201096)

Tags:
Programming / Scripting, User Interface, Special Functions / Features, PVSS, WinCC Open Architecture