@@ -742,6 +742,7 @@ assist.verifyRefCursor = function(connection, tableName, array, done)
742
742
743
743
function fetchRowsFromRS ( rs , array , cb )
744
744
{
745
+ var numRows = 3 ;
745
746
rs . getRows ( numRows , function ( err , rows ) {
746
747
if ( rows . length > 0 ) {
747
748
for ( var i = 0 ; i < rows . length ; i ++ ) {
@@ -947,7 +948,7 @@ assist.verifyRefCursorWithFetchInfo = function(connection, tableName, array, don
947
948
} ,
948
949
function ( err , result ) {
949
950
should . not . exist ( err ) ;
950
- fetchRowsFromRS_fetchas ( connection , result . outBinds . out , array , tableName , callback ) ;
951
+ _verifyFetchedValues ( connection , result . outBinds . out , array , tableName , callback ) ;
951
952
}
952
953
) ;
953
954
} ,
@@ -990,7 +991,7 @@ assist.verifyRefCursorWithFetchAsString = function(connection, tableName, array,
990
991
{ outFormat : oracledb . OBJECT } ,
991
992
function ( err , result ) {
992
993
should . not . exist ( err ) ;
993
- fetchRowsFromRS_fetchas ( connection , result . outBinds . out , array , tableName , callback ) ;
994
+ _verifyFetchedValues ( connection , result . outBinds . out , array , tableName , callback ) ;
994
995
}
995
996
) ;
996
997
} ,
@@ -1006,40 +1007,34 @@ assist.verifyRefCursorWithFetchAsString = function(connection, tableName, array,
1006
1007
] , done ) ;
1007
1008
} ;
1008
1009
1009
- var numRows = 3 ; // number of rows to return from each call to getRows()
1010
-
1011
- function fetchRowsFromRS_fetchas ( connection , rs , array , tableName , cb ) {
1012
- rs . getRows ( numRows , function ( err , rsrows ) {
1013
- if ( rsrows . length > 0 ) {
1014
- for ( var i = 0 ; i < rsrows . length ; i ++ ) {
1015
- ( rsrows [ i ] . CONTENT ) . should . be . a . String ( ) ;
1016
- verifyFetchValues ( connection , rsrows , i , array , tableName ) ;
1017
- }
1018
- return fetchRowsFromRS_fetchas ( connection , rs , array , tableName , cb ) ;
1019
- } else {
1020
- rs . close ( function ( err ) {
1010
+ var _verifyFetchedValues = function ( connection , rs , array , tableName , cb ) {
1011
+ var amount = array . length ;
1012
+ rs . getRows ( amount , function ( err , rows ) {
1013
+ async . each (
1014
+ rows ,
1015
+ queryAndCompare ,
1016
+ function ( err ) {
1021
1017
should . not . exist ( err ) ;
1022
- cb ( ) ;
1023
- } ) ;
1024
- }
1018
+ rs . close ( function ( err ) {
1019
+ should . not . exist ( err ) ;
1020
+ return cb ( ) ;
1021
+ } ) ;
1022
+ }
1023
+ ) ;
1025
1024
} ) ;
1026
- }
1027
1025
1028
- function verifyFetchValues ( connection , rsrows , i , array , tableName ) {
1029
- connection . execute (
1030
- "select CONTENT from " + tableName + " where NUM = " + rsrows [ i ] . NUM ,
1031
- [ ] ,
1032
- {
1033
- fetchInfo :
1034
- {
1035
- "CONTENT" : { type : oracledb . STRING }
1026
+ var queryAndCompare = function ( row , callback ) {
1027
+ var sql = "select content from " + tableName + " where num = " + row . NUM ;
1028
+ connection . execute (
1029
+ sql ,
1030
+ [ ] ,
1031
+ { fetchInfo : { "CONTENT" : { type : oracledb . STRING } } } ,
1032
+ function ( err , result ) {
1033
+ should . strictEqual ( row . CONTENT , result . rows [ 0 ] [ 0 ] ) ;
1034
+ return callback ( err ) ;
1036
1035
}
1037
- } ,
1038
- function ( err , result ) {
1039
- should . not . exist ( err ) ;
1040
- rsrows [ i ] . CONTENT . should . eql ( result . rows [ 0 ] [ 0 ] ) ;
1041
- }
1042
- ) ;
1043
- }
1036
+ ) ;
1037
+ } ;
1038
+ } ; // _verifyFetchedValues()
1044
1039
1045
1040
module . exports = assist ;
0 commit comments