Subject DSQL execute procedure
Author edcurren
Hello all,
I'm having a great deal of difficulty executing a stored procedure
from DSQL. When I execute it I get a message saying:

"Unsuccessful execution caused by system error that does not preclude
successful execution of subsequent statements
message length error (encountered 0, expected 104)"

The stored procedure code is

CREATE PROCEDURE LOGINUSER
(
USERNAME VARCHAR (50) CHARACTER SET NONE,
USERPASSWORD VARCHAR (50) CHARACTER SET NONE
)
RETURNS
(
RIGHTNAME VARCHAR (100) CHARACTER SET NONE
)
AS

DECLARE VARIABLE UserId CHAR(37);
DECLARE VARIABLE GroupId CHAR(37);
DECLARE VARIABLE RightsId CHAR(37);
DECLARE VARIABLE TablePassword VARCHAR(50);

BEGIN
SELECT UserId, UserPassword FROM Users
WHERE UserName=:UserName INTO :UserId, :TablePassword;

IF( :UserId IS NULL ) THEN
EXCEPTION EXC_NO_SUCH_USER;

IF( :TablePassword != :UserPassword ) THEN
EXCEPTION EXC_INCORRECT_PASSWORD;

FOR SELECT GroupId FROM GroupUsers WHERE UserId=:UserId
INTO :GroupId DO
BEGIN
FOR SELECT RightsId FROM AccessControl
WHERE UserId=:GroupId INTO :RightsId DO
BEGIN
SELECT RightName FROM Rights
WHERE RightId=:RightsId INTO :RightName;
SUSPEND;
END
END
FOR SELECT RightsId FROM AccessControl
WHERE UserId=:UserId INTO :RightsId DO
BEGIN
SELECT RightName FROM Rights
WHERE RightId=:RightsId INTO :RightName;
SUSPEND;
END
END

I am setting up the SQL statement in my code like this:
"sprintf(sqlQuery, "EXECUTE PROCEDURE LoginUser('%s', '%s')", OLE2T
(UserName), OLE2T(Password));"

Thanks to all for your help.
Ed