The stored procedure is not executed
Posted in 2000
Topics: Stored Procedures & SPL, Connectivity: ODBC / JDBC / .NET, Security, Permissions & Auditing
Hello! I write an ASP code and want to call my stored procedure from Informix database. To connect to the database I use the next code: <% Set Conn = Server.CreateObject("ADODB.Connection") Conn.Open "DRIVER={INTERSOLV 3.01 32-BIT INFORMIX};UID=informix;DB=database@server;HOST=host;SERV=service;SRVR=se rver;PRO=protocol;PWD=password" %> To execute my procedure I write this <% ProcText = "ProcName('" & Par1 & "','" & Par2 & "'," & Par3 & ")" Conn.Execute(ProcText) %> If this procedure is defined, that it does not return any value, then all is OK. But if it is defined, that it returns any value, then any command of this procedure is not executed. I tryed to use some examles, which were discribed in help and in the book "Active Server Pages 2.0 Professional (Authors: Francis, Fedorov, Harrison, Homer ...)", but these examples did not work. Using the next example <% Set Conn = Server.CreateObject("ADODB.Connection") Conn.Open "data source name", "user id", "password" set cmd = Server.CreateObject("ADODB.Command") set cmd.ActiveConnection = Conn cmd.CommandText = "sp_MyStoredProc" cmd.CommandType = adCmdStoredProc cmd.Parameters.Append cmd.CreateParameter("RETURN_VALUE", _ adInteger, adParamReturnValue) cmd.Parameters.Append cmd.CreateParameter("param1", adChar, _ adParamInput, 30) cmd.Parameters("param1") = "input value" cmd.Execute %> I did not get any error message, but procedure was not executed - it did not modify the data in the table. Using the next example <% Set cn = Server.CreateObject("ADODB.Connection") cn.Open "data source name", "userid", "password" Set cmd = Server.CreateObject("ADODB.Command") Set cmd.ActiveConnection = cn ' Define the stored procedure's inputs and outputs ' Question marks act as placeholders for each parameter for the ' stored procedure cmd.CommandText = "{?=call sp_test(?)}" ' specify parameter info 1 by 1 in the order of the question marks ' specified when we defined the stored procedure cmd.Parameters.Append cmd.CreateParameter("RetVal", adInteger, _ adParamReturnValue) cmd.Parameters.Append cmd.CreateParameter("Param1", adInteger, _ adParamInput) cmd.Parameters("Param1") = 33 cmd.Execute %> I got the error message "Microsoft OLE DB Provider for ODBC Drivers error '80040e10'.No value given for one or more required parameters." Please, help me to resolve this problem! Sent via Deja.com http://www.deja.com/ Before you buy.
alexn@dati.lv wrote:
> Hello!
> I write an ASP code and want to call my stored procedure from Informix
> database. To connect to the database I use the next code:
> <%
> Set Conn = Server.CreateObject("ADODB.Connection")
> Conn.Open "DRIVER={INTERSOLV 3.01 32-BIT
> INFORMIX};UID=informix;DB=database@server;HOST=host;SERV=service;SRVR=se
> rver;PRO=protocol;PWD=password"
> %>
> To execute my procedure I write this
> <%
> ProcText = "ProcName('" & Par1 & "','" & Par2 & "'," & Par3 & ")"
> Conn.Execute(ProcText)
> %>
If that is meant to be interpreted by the Informix database, you have to
use:
EXECUTE PROCEDURE ProcName( ... )
> If this procedure is defined, that it does not return any value, then
> all is OK. But if it is defined, that it returns any value, then any
> command of this procedure is not executed.
Yes; if your procedure returns data, you have to treat it like a SELECT
statement -- declare a cursor for the statement, then open, fetch, close.
> I tryed to use some examles, which were discribed in help and in the
> book "Active Server Pages 2.0 Professional (Authors: Francis, Fedorov,
> Harrison, Homer ...)", but these examples did not work.
[...other material snipped...]
--
Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net)
Guardian of DBD::Informix v0.95 -- see http://www.perl.com/CPAN
#include <disclaimer.h>