Page 1 of 1

Sybase Stored Procedure w/ output parameters does not work

Posted: 26.03.2012, 22:16
by Ðerek wildstar
Hello!

I'm having trouble running a procedure (TZStoredProc) that contains two output parameters. The error occurs exactly in the parameters, see:


Procedure expects parameter @ p_modulo_por_menu pCodModulo, Which was not supplied.
Procedure expects parameter @ p_modulo_por_menu pNomeModulo, Which was not supplied.

My database is Sybase (unfortunately, because we use it here at work). Previously we were using BDE and we are trying to use to get rid ZeosLib definitely BDE and all its eccentricities.

Using TStoredProc (standard BDE) the procedure runs smoothly. Any ideas?

Posted: 26.03.2012, 22:39
by Ðerek wildstar
A new information: This error occurs on the second time I run TZStoredProc.ExecProc. Very strange error.

first time:

STPRModuloPorMenu.ParamByName('@pNomeMenu').AsString := 'carlos';
STPRModuloPorMenu.ExecProc;

No error!

Second time:

STPRModuloPorMenu.ParamByName('@pNomeMenu').AsString := 'carlos';
STPRModuloPorMenu.ExecProc;

Error!

Posted: 29.03.2012, 19:49
by Ðerek wildstar
More information:

The problem is that the on the second call the params are being cleared. But why this is done?

Code: Select all

procedure TZAbstractRODataset.ExecSQL;
begin
  CheckConnected;
  Connection.ShowSQLHourGlass;
  try
    if Active then Close;

    CheckSQLQuery;
    CheckInactive;

    if (Statement = nil) or (Statement.GetConnection.IsClosed) then
      Statement := CreateStatement(FSQL.Statements[0].SQL, Properties)
    else
      if (Assigned(Statement)) then 
         Statement.ClearParameters;

    SetStatementParams(Statement, FSQL.Statements[0].ParamNamesArray,
      FParams, FDataLink);

    FRowsAffected := Statement.ExecuteUpdatePrepared;
  finally
    Connection.HideSQLHourGlass;
  end;
end;
On the first call the Statement is created. On the second all parameters are cleared (Statement.ClearParameters). Why this is done? I've made a test, removing the else part and the procedure works perfectly.

The question is: This is working correctly for other databases?

Posted: 25.04.2012, 23:31
by mdaems
Ðerek wildstar,

Seems you're using the 6.6 version. I don't know why these lines are there. I tried to remove them and they did not have any impact on when testing with firebird, sqlite and mysql. Failed to test with oracle and postgres for some strange problem on this computer at the moment.

This code has been reorganised in 7.X. Did you check if all works fine there?

Mark