示例#1
0
        public SFResultSet(QueryExecResponseData responseData, SFStatement sfStatement, CancellationToken cancellationToken)
        {
            columnCount           = responseData.rowType.Count;
            _currentChunkRowIdx   = -1;
            _currentChunkRowCount = responseData.rowSet.GetLength(0);

            this.sfStatement = sfStatement;

            if (responseData.chunks != null)
            {
                // counting the first chunk
                _totalChunkCount = responseData.chunks.Count + 1;
                _chunkDownloader = new SFChunkDownloader(columnCount,
                                                         responseData.chunks,
                                                         responseData.qrmk,
                                                         responseData.chunkHeaders,
                                                         cancellationToken);
            }

            _currentChunk       = new SFResultChunk(responseData.rowSet);
            responseData.rowSet = null;

            sfResultSetMetaData = new SFResultSetMetaData(responseData);

            updateSessionStatus(responseData);
            isClosed = false;
        }
        internal static int CalculateUpdateCount(this SFBaseResultSet resultSet)
        {
            SFResultSetMetaData metaData      = resultSet.sfResultSetMetaData;
            SFStatementType     statementType = metaData.statementType;

            int updateCount = 0;

            switch (statementType)
            {
            case SFStatementType.INSERT:
            case SFStatementType.UPDATE:
            case SFStatementType.DELETE:
            case SFStatementType.MERGE:
            case SFStatementType.MULTI_INSERT:
                for (int i = 0; i < resultSet.columnCount; i++)
                {
                    updateCount += resultSet.GetValue <int>(i);
                }
                break;

            case SFStatementType.COPY:
                updateCount = resultSet.GetValue <int>(3);
                break;

            case SFStatementType.SELECT:
                updateCount = -1;
                break;

            default:
                updateCount = 0;
                break;
            }

            return(updateCount);
        }
        public SFResultSet(QueryExecResponseData responseData, SFStatement sfStatement)
        {
            execFirstChunkData   = responseData;
            columnCount          = responseData.rowType.Count;
            currentChunkRowIdx   = -1;
            currentChunkRowCount = responseData.rowSet.GetLength(0);
            currentChunkIndex    = 0;

            this.sfStatement = sfStatement;

            if (responseData.chunks != null)
            {
                // counting the first chunk
                totalChunkCount = responseData.chunks.Count + 1;
                chunkDownloader = new SFChunkDownloader(responseData.rowType.Count,
                                                        responseData.chunks,
                                                        responseData.qrmk,
                                                        responseData.chunkHeaders);
            }

            currentChunk = new SFResultChunk(responseData.rowSet);

            sfResultSetMetaData = new SFResultSetMetaData(responseData);

            updateSessionStatus(responseData);
            isClosed = false;
        }
        internal static int CalculateUpdateCount(this SFBaseResultSet resultSet)
        {
            SFResultSetMetaData metaData      = resultSet.sfResultSetMetaData;
            SFStatementType     statementType = metaData.statementType;

            long updateCount = 0;

            switch (statementType)
            {
            case SFStatementType.INSERT:
            case SFStatementType.UPDATE:
            case SFStatementType.DELETE:
            case SFStatementType.MERGE:
            case SFStatementType.MULTI_INSERT:
                resultSet.Next();
                for (int i = 0; i < resultSet.columnCount; i++)
                {
                    updateCount += resultSet.GetValue <long>(i);
                }

                break;

            case SFStatementType.COPY:
                resultSet.Next();
                var index = resultSet.sfResultSetMetaData.getColumnIndexByName("rows_loaded");
                if (index >= 0)
                {
                    updateCount = resultSet.GetValue <long>(index);
                }
                break;

            case SFStatementType.SELECT:
                updateCount = -1;
                break;

            default:
                updateCount = 0;
                break;
            }

            if (updateCount > int.MaxValue)
            {
                return(-1);
            }

            return((int)updateCount);
        }