I wrote this procedure in MySQL (Server 5.5)
DELIMITER $$ DROP PROCEDURE IF EXISTS `InsertList` $$ CREATE DEFINER=`root`@`localhost` PROCEDURE `InsertList`(IN fName VARCHAR(20), IN fType VARCHAR(3), IN fFood varchar(20), Out fResult int) BEGIN insert into tblguest (firstname, confirm, food) values (fName, fType, fFood); select count(id) from tblguest into fResult; END $$ DELIMITER ;
When I call this procedure from MySQL Query Browser, it returns as expected
Call InsertList ('V1', 'No', 'F1', @result); Select @result;
-> It successfully returns the number of identifiers in the table
I wrote the following code in VB6
Dim res As Integer On Error GoTo chkErr Set cmd = New ADODB.Command cmd.ActiveConnection = cn cmd.CommandType = adCmdStoredProc cmd.CommandText = "InsertList" cmd.Parameters.Append cmd.CreateParameter("fName", adVarChar, adParamInput, 20, Text3.Text) cmd.Parameters.Append cmd.CreateParameter("fType", adVarChar, adParamInput, 3, Text2.Text) cmd.Parameters.Append cmd.CreateParameter("fFood", adVarChar, adParamInput, 20, Text1.Text) cmd.Parameters.Append cmd.CreateParameter("fResult", adInteger,adParamOutput) cmd.Execute res = cmd("fResult") MsgBox res Exit Sub chkErr: Select Case Err.Number Case Else Text4.Text = Err.Number & " - " & Err.Description End Select
But when he tries to run the cmd.execute , he throws the following error:
-2147467259 - [MySQL] [ODBC driver 5.1] [mysqld-5.5.34] OUT or INOUT argument 4 for regular dbtest.InsertList is not a variable or NEW pseudo-variable in a BEFORE trigger
I saw codes that work on SQL, is it true that MySQL has a problem using a stored procedure with an OUT parameter?