Google Answers Logo
View Question
 
Q: Syntax for Call Oracle SP Via ADO Command Object ( Answered 3 out of 5 stars,   2 Comments )
Question  
Subject: Syntax for Call Oracle SP Via ADO Command Object
Category: Computers > Programming
Asked by: sdunn-ga
List Price: $5.00
Posted: 18 Jul 2002 09:12 PDT
Expires: 17 Aug 2002 09:12 PDT
Question ID: 42511
Call Oracle Stored Procedure from Visual Basic using ADO 2.6 - ADODB
Command object.

I need the CreateParameter parameter values to call the following
stored procedure in Oracle 7:

CREATE OR REPLACE PROCEDURE DB1.SET_VALUES(x IN OUT VARCHAR) as
y varchar2(500) := upper('all');
[rest of sp logic snipped]

Thanks,
S
Answer  
Subject: Re: Syntax for Call Oracle SP Via ADO Command Object
Answered By: gopalkamat-ga on 18 Jul 2002 12:48 PDT
Rated:3 out of 5 stars
 
Dear sdunn-ga,

Your answer should look somewhat like this:

'-------------------------------------------------------------------------
Dim x
'Store the value of the input parameter in x (in this example, I'll
'assign "abc" to it
x = "abc"
'Store your database connection string here
Dim strConnection
strConnection = ""
'Other variables
Dim objConnection, objRecordSet, objCommand, objNameParam1
Set objConnection = Server.CreateObject("ADODB.Connection")
Set objRecordSet = Server.CreateObject("ADODB.RecordSet")
Set objCommand = Server.CreateObject("ADODB.Command")
Set objNameParam1 = .CreateParameter("x", adBSTR, adParamInputOutput,
,x)
With objConnection
	.ConnectionString = strOraConnection
	.Open
End with
With objCommand
.ActiveConnection = objConnection 
.CommandType = adCmdText
.CommandText = "{call DB1.SET_VALUES(?,{resultset 10000, x})}"  
.Parameters.Append objNameParam1
Set objRecordSet = .Execute()
End With
'Display error message is error occurs
If Err.number <> 0 Then
	Response.Clear
	DisplayErrorOnly(Err.Description)
	Response.End
End If
'Get output of Stored Procedure in a variable...
x = objCommand.Parameters("x").Value
'-------------------------------------------------------------------------

This code snippet is a modification of an actual code that I used in
Visual Basic to connect to Oracle and run a stored procedure.  You may
or may not have to make a few changes to this, and I presume you know
VB well enough to be able to do that.

Thanks for using Google Answers!

Regards,
gopalkamat-ga

Clarification of Answer by gopalkamat-ga on 23 Jul 2002 13:14 PDT
Sdunn-ga,

The question that you had asked was "I need the CreateParameter
parameter values to call the stored procedure".  From the comment put
in by you, it is clear that there was an issue with the Oracle Stored
Procedure, and not the answer given by me.

I believe I deserved a better rating.  Thanks for using Google
Answers.

regards,
gopalkamat-ga
sdunn-ga rated this answer:3 out of 5 stars
A good, thourough answer, but not the resolution to my problem. As I
later found, the issue was with handling Oracle's VARCHAR datatype. I
changed it to VARCHAR2 and it worked.

Thanks,
Scott

Comments  
Subject: Re: Syntax for Call Oracle SP Via ADO Command Object
From: bexar-ga on 18 Jul 2002 09:27 PDT
 
I have an article on this subject at:

http://www.15seconds.com/issue/000810.htm

It goes step-by-step on how to call a stored procedure. You may find it helpful.

Al
Subject: Re: Syntax for Call Oracle SP Via ADO Command Object
From: sdunn-ga on 22 Jul 2002 12:02 PDT
 
That covers everything. My problem wasn't so much how to do it, but
what the problem was with my specific instance. Turns out the issue
was with handling the Oracle datatype VARCHAR. I changed it to
VARCHAR2 and it worked.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy