I have a databae in Oracle. I've successfully queried it using the following code:
Sub AnalyzeDBATables()
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim col As Integer
Dim row As Integer
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
cn.Open ( _
"User ID=" & _
";Password=" & _
";Data Source=" & _
";Provider=MSDAORA.1")
rs.Open "select * from dba_tables", cn
col = 0
' First Row: names of columns
Do While col < rs.Fields.Count
Cells(1, col + 1) = rs.Fields(col).Name
col = col + 1
Loop
' Now actual data as fetched from select statement
row = 1
Do While Not rs.EOF
row = row + 1
col = 0
Do While col < rs.Fields.Count
Cells(row, col + 1) = rs.Fields(col).Value
col = col + 1
Loop
rs.MoveNext
Loop
End Sub
It appears to work with simple SQL statements. However my problem arises with retrieving data from some rather long PLSQL code that utilizes DBMS_OUTPUT.put_line
. My end data is returned in CSV values.
The more obvious solution might be to try to turn this output into a true table in Oracle at the end, and using SELECT with the above code to be able to harvest it. However I only have read priveleges to the database, so I really need to be able to harvest the output.
Is there a way to harvest the response from DBMS_OUTPUT.put_line
that I could then parse within the macro. I've tried even a simple harvest of DBMS_OUTPUT.put_line('Hi');
but I get an error runtime error 3704
Let me know what your thoughts are!