Pulling data from Oracle tables

danny

New Member
Joined
Jan 21, 2004
Messages
1
I have a list of about 300 unique ID's in an excel worksheet. What I want to do is pull all the related records (with all the associated fields) out of an ORACLE database. The Oracle database has about 250000 records so pulling all the records and then picking out the records I need will grind the machine to a halt, and using the exceptions and entering each unique ID seperately is very labourous as well. Is there an easy way to pull the records listed in the excel file quickly and easily?

BTW, I'm using Excel 2002
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Not tested BUT DSN is ODBC connection name. Prefer to connect using DSN as opposed to lengthy connection string. Choice is yours.

Also - this requires the ActiveX Data Objects Library (highest number) to be referenced in VBE References.

Code:
Sub GET_DETAILS()

Dim Conn as ADODB.Connection
Set Conn = New ADODB.Connection

Conn.Open "DSN=ORACLE_DB"

Sheets("sheet1").Select
n = 1
Do Until n > 300
      Dim RS as ADODB.Recordset
      SQL = "Select * From Oracle Table where ID = '" & Cells(n,1) & "'"
      RS = Conn.Execute(SQL)
      If RS.EOF = False then
            Cells(n,2).CopyFromRecordset RS
      End If
      RS.Close
n = n + 1
Loop

Conn.Close
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,823
Members
449,049
Latest member
cybersurfer5000

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top