static public int calculateUpdateCount ( SFBaseResultSet resultSet ) throws SFException , SQLException { int updateCount = 0 ; SFStatementType statementType = resultSet . getStatementType ( ) ; if ( statementType . isDML ( ) ) { while ( resultSet . next ( ) ) { if ( statementType == SFStatementType . COPY ) { SFResultSetMetaData resultSetMetaData = resultSet . getMetaData ( ) ; int columnIndex = resultSetMetaData . getColumnIndex ( "rows_loaded" ) ; updateCount += columnIndex == - 1 ? 0 : resultSet . getInt ( columnIndex + 1 ) ; } else if ( statementType == SFStatementType . INSERT || statementType == SFStatementType . UPDATE || statementType == SFStatementType . DELETE || statementType == SFStatementType . MERGE || statementType == SFStatementType . MULTI_INSERT ) { int columnCount = resultSet . getMetaData ( ) . getColumnCount ( ) ; for ( int i = 0 ; i < columnCount ; i ++ ) updateCount += resultSet . getLong ( i + 1 ) ; // add up number of rows updated } else { updateCount = 0 ; } } } else { updateCount = statementType . isGenerateResultSet ( ) ? - 1 : 0 ; } return updateCount ; }
Calculate number of rows updated given a result set Interpret result format based on result set s statement type