Accessing an Oracle Server via Scripts

<< Click to Display Table of Contents >>

 

Accessing an Oracle Server via Scripts

Scripts are programming language modules that allow users to create source code, which allows great flexibility to associate actions to specific events. Each item of an Elipse E3 project has a list of previously linked events. So, users can create programs that are executed whenever an event occurs.

Elipse E3 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 E3 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 object 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.

Was this page useful?