Hi iuridicus,
I searched google for such a thing and came up with this article about connecting excel to an oracle database.
Developers can use the OO4O In-Process Automation Server to connect to Oracle database servers and execute SQL or PL/SQL procedures through COM Automation Objects. You can also use the In-Process Server by creating a COM object for a session from its interface, "OracleInProcServer.XOraSession," and accessing subobjects, as shown in this example using Visual Basic:
CODE
Set objSession = CreateObject("OracleInProcServer.XOraSession")
Set objDatabase = objSession.OpenDatabase("","scott/tiger",0)
With a database object, you can query records from the database or execute DDL or DML statements directly. For example, here's a VBA script that you can run from inside Microsoft Excel to fetch all the data from the EMP table into worksheet cells:
CODE
Sub GetEmployees()
' Use OO4O
Set objSession = CreateObject("OracleInProcServer.XOraSession")
Set objDatabase = objSession.OpenDatabase("", "scott/tiger", 0)
Sql = "select * from emp"
Set oraDynaSet = objDatabase.DBCreateDynaset(Sql, 0)
If oraDynaSet.RecordCount > 0 Then
oraDynaSet.MoveFirst
For x = 0 To oraDynaSet.Fields.Count - 1
Cells(1, x + 1) = oraDynaSet.Fields(x).Name
Cells(1, x + 1).Format = Bold
Next
For y = 0 To oraDynaSet.RecordCount - 1
For x = 0 To oraDynaSet.Fields.Count - 1
Cells(y + 2, x + 1) = oraDynaSet.Fields(x).Value
Next
oraDynaSet.MoveNext
Next
End If
Set objSession = Nothing
Set objDatabase = Nothing
End Sub
While it's possible to fetch data from an external datasource into an Excel spreadsheet through the Data/External Datasource function, this macro has much more direct control, allowing you to specify exactly how the data is read into the spreadsheet; and, because the macro doesn't use as many layers to get to the Oracle database, it should be faster. It also provides additional functionality, including the ability to store and retrieve blobs (such as images).
Here is the link to that article.
<<http://builder.com.com/5100-6388-5219076.html>>
Hope this helps.
Comment/Reply (w/o sign-up)