<< Click to Display Table of Contents >>
Accessing Oracle via Scripts |
Scripts are programming language modules, in which users can create source code that allows great flexibility to associate actions to specific events. Each item of an Elipse Power project has a list of previously associated events. So, users can create programs that are executed whenever an event occurs.
Elipse Power uses VBScript (Visual Basic Script) in its scripts, and thus it can instantiate any system-registered ActiveX object. To access a Database, the most commonly used ActiveX is ADO (ActiveX Data Object), which can be easily handled in Elipse Power scripts.
1.First, users must create an ADO connection, which can be performed by using the next script.
Set DBConnection = CreateObject("ADODB.Connection")
DBConnection.Open "Provider=MSDAORA;_
DataSource=connectionOracle;User_
ID=UserID;Password=passwd"
2.After creating a connection, users can execute a SQL command directly through that connection using the next script.
DBConnection.Run _
"UPDATE Table SET name = 'John' WHERE id = 10"
3.Users can also view all records, which are returned as a Recordset (query) by using the next script.
Set Recordset = CreateObject("ADODB.Recordset")
Recordset.Source = "Table"
Recordset.ActiveConnection = DbConnection
Recordset.CursorType = 1 ' adOpenKeyset
Recordset.LockType = 3 ' adLockOptimistic
Recordset.Open
4.Then users can browse the returned table by using the MoveNext and MovePrevious commands, as well as many other ADO commands. Users can also use a SQL query to handle specific parts of a table, by using the Source property.