bde 16bit, interbase, generator-problem

hi,

I think, I found a bug in the bde16 bit.
The generator value, returned via a stored procedure with the follwing code,
is wrong !!! ;(

all is ok under 32767, well after maybe this a buffer overflow occurs,
the value is negativ.

This si my code.
The MBInfo is for testing.

HELP me pls
What can I do. Changin to 32bit is not possible.

TiA

Heiko

function Table_GetNewId(const theTableName: String;
  var theNewId: Longint; var theErrorStr: String): Boolean;
var
  SP: TStoredProc;
begin
  Result:= False;

  theNewId:= -1;
  theErrorStr:= '';

  try
    SP:= TStoredProc.Create(NIL);
    SP.DataBaseName:= jrd.DataBaseName;
    SP.StoredProcName:= UpperCase(theTableName)+'_NEWID';
    SP.ExecProc;

    MBInfo(SP.Params[0].AsString);

    theNewId:= StrToInt(SP.Params[0].AsString);

    SP.Free;

    Result:= True;
  except
    on E: Exception do
    begin
      theErrorStr:= E.message;
     {$IFDEF DEBUG}
      MBDebug(sFormName+'Table_GetNewId'+#13#10+theTableName+E.message);
     {$ENDIF}
    end;
  end;
end;  { Table_GetNewId }