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

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

DonkeyOte

MrExcel MVP
Joined
Sep 6, 2002
Messages
9,123
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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,151,885
Messages
5,766,936
Members
425,388
Latest member
Cave_Johnson

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
Top