Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running Oracle's Stored Procedure 1

Status
Not open for further replies.

orna

Programmer
Apr 2, 2002
314
IL
Hi

I need to run an Oracle procedure.
Get this error "cannot execute a select query"
Can someone See the problem here??
Thanks for any help

Set qryOracleProc = CurrentDb.CreateQueryDef("")
qryOracleProc.Connect= "ODBC;DSN=ORAxx;PWD=xxxx;DBA=W
sql = "begin OracleProc(1);end;"
qryOracleProc.sql = sql
qryOracleProc.ReturnsRecords = False
qryOracleProc.ODBCTimeout = 60
qryOracleProc.Execute
 
I'd use an ADODB.Command object.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 

PHV is correct (as always)...

Code:
Dim con1 As New ADODB.Connection 'con to oracle

con1.Open "Provider=MSDAORA;" & "Data Source=DATABASE;" & "User Id=APPSLOGIN;" & "Password=APPSPWD"

 
Thanks PHV & Fattire

I Tried the connection:

con1.Open "Provider=MSDAORA;" & "Data Source=MyDATABASE;" & "User Id=MyUser;" & "Password=MyPWD"

I get an error "Oracle Error Qccurred".
 
You need to substitute in the values MYDATABASE, MyUser and MyPWD with the values relevant to your DB.

Hope this helps

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
If they're variables try something like:
Code:
"Provider=MSDAORA;Data Source=" & MyDATABASE & ";User Id=" & MyUser & ";Password=" & MyPWD
Hope this helps

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Thanks HarleyQuinn
I did insert the right parameters and yet the same error rise.

 
What Oracle error do you get returned?

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
the connection works:
con1.Open "Provider=MSDAORA;Data Source=xxxx;User Id=yyyy;Password=zzzz"

and i build a pass-through query - "Test".

How can i run the query through con1?
 
If you want to do this through ADO then use something like:
Code:
Dim rs As ADODB.Recordset
Dim cn As ADODB.Connection

Set rs = New ADODB.Recordset
Set cn = New ADODB.Connection

cn.Open ("Your connection string...")

Set rs = cn.Execute("The SQL from your pass through query...")
    'you've got the recordset, use it for what you want

'Clean up
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
Please note though, running a query on an Oracle DB through ADO (as shown above) is generally significantly different code than running an SP from VBA.

Hope this helps

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
HarleyQuinn, you did it
Many Thanks!!!!!!!
 
Glad I could help, thanks for the star [smile]

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top