TSQLStoredProc.NextRecordSet

2005-08-19
2013-05-01
  • Sebastien78
    Sebastien78
    2005-08-19

    In SQLexpr.pas TSQLStoredProc.NextRecordSet

    When trying to get Next Record Set. It is Calling ODBC methode SQLCloseCursor.

    After that ODBC methode SQLMoreResult failed with error code -1.

    If I remove from DbxOpenOdbc.pas in TSqlCursorOdbc.ClearCursor line [SQLCloseCursor(fHStmt);] everything work fine. I'm able to retreive every RecordSet of my Stored Procedure.

    Do you have a other way to correct this probleme?

    procedure TSqlCursorOdbc.ClearCursor;
    var
      OdbcRetcode: OdbcApi.SqlReturn;
    begin

      if not fOwnerCommand.fStmtFreed then
      begin
        fOwnerCommand.fStmtFreed := True;
        if fHStmt <> SQL_NULL_HANDLE then
        with fOwnerDbxDriver.fOdbcApi do
        begin

          if (fOwnerDbxConnection.fStatementPerConnection > 0) then
            dec(fOwnerCommand.fDbxConStmtInfo.fDbxConStmt.fActiveCursors);
          dec(fOwnerDbxConnection.fActiveCursors);

    //Remove this line here****************
    //      SQLCloseCursor(fHStmt);
    //Remove this line here****************
          OdbcRetcode := SQLFreeStmt(fHStmt, SQL_UNBIND);
          if OdbcRetcode <> OdbcApi.SQL_SUCCESS then
            OdbcCheck(OdbcRetcode, 'SQLFreeStmt - SQL_UNBIND');
          OdbcRetcode := SQLFreeStmt(fHStmt, SQL_RESET_PARAMS);
          if OdbcRetcode <> OdbcApi.SQL_SUCCESS then
            OdbcCheck(OdbcRetcode, 'SQLFreeStmt - SQL_RESET_PARAMS');
        end;
      end;

    end;

     
    • It is shown only on RDBMS with restriction by quantity of open cursors. At you probably MSSQL or MySQL.

      Try the following correction "DbxOpenOdbc.pas":
      ------------------------------------------------
      procedure TSqlCursorOdbc.ClearCursor;
      ...
      begin
      ...
            {+}
            if not fStoredProc then
            {+.}
              SQLCloseCursor(fHStmt);
      ------------------------------------------------
      ps:
      What at you RDBMS?

      Pay attention to the following:
      -----------
      function TSqlCommandOdbc.getNextCursor(var Cursor: ISQLCursor): SQLResult;
      { TODO : getNextCursor - THIS HAS NOT BEEN TESTED }
      -----------
      About one today nobody tested work with cursors :(
      You the first for whom this functionality was necessary !!!

       
    • if not fOwnerCommand.fStoredProc then

       
    • Sebastien78
      Sebastien78
      2005-08-19

      It's work fine for me.

      the Function getNextCursor look like doing is joke correctly.

      Thanks a lot for your help and for quick answer

      For you infomation I'm using iseries ClientAccess Odbc driver. with all this flag
      coMapCharAsBDE=1;coEnableBCD=0;coTrimChar=1;EmptyStrParam=1;coLockMode=-1

      SB

       
    • Sebastien78
      Sebastien78
      2005-08-19

      What did I need to do if I want this change to be in the next release of Open source dbExpress drivers?

       
      • I have included this correction in the following version.
        ---------------
        Version 3.024
        -------------------------
        + added support Delphi 2005 Win32.
        + added Connection Timeout option. Connection string example: "DSN=MyDsn;coConTimeout=60".
          added support connection parameter CONN_TIMEOUT
        + added: connection option coBcd2Exp:
            // https://sourceforge.net/forum/forum.php?thread_id=1251922&forum_id=119358
            Changed BCD2Str.
            In this option BCD will converted into exp format.
        + changed: Str2BCD. Removed dependency from DecimalSeparator.
        + added: connection option 'coNumSepr' - coNumericSeparator.
             It option allow define 'Decimal Separator' transmitted into odbc driver.
             Example (uses ... DbxOpenOdbcInterface;):
               SQLConnection1.SQLConnection.SetOption(
                 TSQLConnectionOption(xeConnDecimalSeparator), Integer(Ord(','))
               );
             For " Oracle ODBC the Driver " DesimalSeparator is detected out automatically (look:
               function TSqlConnectionOdbc.RetrieveDbmsOptions).
        + added: connection option coSafeMode (default = true).
            (Maximum handling any errors. It is critical for app servers...).
        + changed: identify readonly fields.
        ...