Problems with parameters passed to package function via ODBC/ASP
637606May 5 2008 — edited May 5 2008If someone knows the answer to this one, I'll be extremely grateful!
I am trying to call a function from a package, from an ASP web page.
Depending on what I try, I get one of two errors:
1. Microsoft OLE DB Provider for ODBC Drivers (0x80040E10)
No value given for one or more required parameters
-or-
2. Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Oracle][ODBC]Syntax error or access violation.
I am able to call this function through SQL Developer, using the following code:
DECLARE
p_result varchar2(1);
p_code varchar2(3);
BEGIN
p_code := 'W';
p_result := BANINST1.gb_stvcamp.F_CODE_EXISTS(p_code);
dbms_output.PUT_LINE(p_result);
END;
That's great, but I need to be able to do this in a web application. The problem seems to be getting the parameters through. The basic set up I'm trying looks like this:
Dim objCmd
Dim objParameter, objParameter2
Set objCmd = CreateObject("ADODB.Command")
objCmd.ActiveConnection = Db
objCmd.CommandType = adCmdStoredProc
Set objParameter = objCmd.CreateParameter
objParameter.Name = "p_code"
objParameter.Type = 200 'varchar
objParameter.Direction = 1 '1=input, 2=output, 3=in/out, 4=returnvalue
objParameter.Size = 3
objCmd.Parameters.Append objParameter
objCmd("p_code") = "W"
Set objParameter2 = objCmd.CreateParameter
objParameter2.Name = "output"
objParameter2.Type = 200 'varchar
objParameter2.Direction = 2 '1=input, 2=output, 3=in/out, 4=returnvalue
objParameter2.Size = 1
objCmd.Parameters.Append objParameter2
objCmd.CommandText = "call BANINST1.gb_stvcamp.f_code_exists(?);"
objCmd.Execute
I've tried it with every imaginable combination of { } braces in CommandText, with and without "call", with p_code in the parenthesis, hard-coding a literal value as a the parameter, without the output parameter, changed order of the parameters, etc. etc.
In general, I get the first error (No value given for required parameter") if I include a ? as the parameter. Anything else (empty, commas, etc) produces the second error ('syntax error').
I am using the latest ODBC driver from Oracle which is running on my PC with the Oracle SQL Developer (which was required before I could install or use it).
Any clues? This is fairly important as we need to be able to call Banner (ERP) API's through other programs.... but I'm at the end of my rope on this one!
Thank you for any advice!!
Al