Page 1 of 1

Problems with stored procedures in MSSQL

Posted: 21.09.2005, 07:32
by musicones
Hi,

I've got problems with stored procedures. I get this error message:

english translated:
The TESTPROC-procedure expects the @NAME1-Parameter; it hasn't been assigned.

german original:
Die TESTPROC-Prozedur erwartet den @NAME1-Parameter; dieser wurde nicht übergeben.


[syntax="delphi"]
procedure TZeosMSSQLProviderTestCase.Test_Procedure2;
const
sqlProcedure = 'TESTPROC';
sqlParamOut = 'ParamOut';
var
Connection: IDBConnection;
StoredProc: IDBProcedure;
ResultSet: IDBResultSet;
begin

{ Connect to Database - works }
Connection := FConnectionFactory.CreateConnection;
Connection.Open;

{ CALL PROCEDURE }
StoredProc := Connection.CreateProcedure(sqlProcedure);

// Do I not assign the parameter here??
StoredProc.RegisterOutParameter(0, vtString);
StoredProc.SetString(0, sqlParamOut);
//

ResultSet := StoredProc.ExecuteQuery;

{ Check }
Check(ResultSet.Next);
Check(ResultSet.GetString(0) = sqlParamOut);

{ Close ResultSet }
ResultSet.Close;

{ Close Connection }
Connection.Close;

end;
[/syntax]

Here is the stored procedure in MSSQL, maybe there is something wrong with it. I tried with and without OUTPUT, no changes.

[syntax="sql"]
CREATE PROCEDURE TESTPROC @NAME1 VARCHAR (20) OUTPUT
AS
declare @SAMENAME VARCHAR (20)
SELECT @SAMENAME = @NAME1
GO
[/syntax]

thanks and regards
musicones

[edit="Michael"]changed "code"-tags to "syntax"-tags to improve visibility.[/edit]
[edit="musicones"]thanks for changing, I didn't know about the "syntax"-tags. Cool feature.[/edit]