You have to do this from Excel:
You are looking for information on the methods available for connecting
MS-Excel 97 to Oracle using ODBC.
Search Words:
=============
MICROSOFT
MSQUERY
QUERY
Solution Description:
=====================
There are two main methods available for connecting from MS-Excel to Oracle
using ODBC. The first is via MS-Query and the second is using VBA. Both these
methods require that you have a working Oracle ODBC datasource defined in the
ODBC administrator.
Connecting to Oracle using MS-Query:
--------------------------
Pros: - Automated so no coding is involved
Cons: - Formatting layout is limited to the SQL query's format
- Requires the use of a file DSN which is not yet creatable via the
Oracle ODBC driver
Note: To create a manual Oracle File DSN that points to an existing Oracle
System DSN, use Notepad to create a file with a .dsn extension (eg.
myoracle.dsn) that has the following two lines in it's document:
[ODBC]
DSN=<MyDSN> -- where <MyDSN> is the name of an existing System DSN
This type of data import is performed via the Excel menu bar. Follow these
steps:
1) Click on the DATA option on the menu bar
2) Click on the GET EXTERNAL DATA option on the menu dropdown list
3) Click on the CREATE NEW QUERY option to launch MS-Query
4) Connect to Oracle using a File DSN as described above
5) A Query Wizard will appear to allow you to select/format data
Connecting to Oracle using MS-VBA:
--------------------------
Pros: - Formatting layout is completely customizable
Cons: - Involves coding and a knowledge of MS-Basic
This type of data import is performed via an Excel macro. Follow these steps:
1) Click on the TOOLS option on the menu bar
2) Click on the CUSTOMIZE option on the menu dropdown list
3) Check the FORMS option in the options list
4) Create a button on the spreadsheet using the "Forms" toolbar
5) This will create a default macro named Buttonx_Click
6) In the Visual Basic editor, go to the MENU->TOOLS->REFERNECES and check MS
RDO 2.0
7) Copy the following code in the Buttonx_Click macro to finish the sample:
' Rdo Sample Code
Sub Button1_Click()
Dim RdoEnvironment As RdoEnvironment
Dim RdoDatabase As rdoConnection
Dim RdoRecordset As rdoResultset
Dim connstr As String
Dim sqlstmt As String
connstr = "DSN=ORA32;UID=SCOTT;PWD=T
sqlstmt = "select * from emp"
Set RdoEnvironment = rdoEnvironments(0)
Set RdoDatabase = RdoEnvironment.OpenConnect
connstr)
Set RdoRecordset = RdoDatabase.OpenResultset(
rdOpenDynamic, rdConcurRowver)
r = 10
c = 1
While Not RdoRecordset.EOF
ActiveSheet.Cells(r, c + 0) = RdoRecordset("EMPNO").Valu
ActiveSheet.Cells(r, c + 1) = RdoRecordset("ENAME").Valu
ActiveSheet.Cells(r, c + 2) = RdoRecordset("JOB").Value
ActiveSheet.Cells(r, c + 3) = RdoRecordset("MGR").Value
ActiveSheet.Cells(r, c + 4) = RdoRecordset("HIREDATE").V
ActiveSheet.Cells(r, c + 5) = RdoRecordset("SAL").Value
ActiveSheet.Cells(r, c + 6) = RdoRecordset("COMM").Value
ActiveSheet.Cells(r, c + 7) = RdoRecordset("DEPTNO").Val
RdoRecordset.MoveNext
r = r + 1
Wend
End Sub
-- or --
' MS-Query API Sample Code
Sub Button1_Click()
Dim connstr As String
Dim sqlstmt As String
connstr = "ODBC;DSN=ORA32;UID=SCOTT;
sqlstmt = "select * from emp"
With ActiveSheet.QueryTables.Ad
Destination:=Range("A10"))
ActiveSheet.QueryTables(1)
ActiveSheet.QueryTables(1)
End With
Main Topics
Browse All Topics





by: hartPosted on 2004-03-31 at 01:30:20ID: 10722178
Also what i was thinking was to send the path and file name of the file as in parameters to the stored procedure and rest should be done by the sp..
can this be done :-)
Regards
Hart