@@ -740,7 +740,6 @@ assist.verifyRefCursor = function(connection, tableName, array, done)
740740 ] , done ) ;
741741} ;
742742
743- var numRows = 3 ; // number of rows to return from each call to getRows()
744743function fetchRowsFromRS ( rs , array , cb )
745744{
746745 rs . getRows ( numRows , function ( err , rows ) {
@@ -915,4 +914,132 @@ assist.compareNodejsVersion = function(nowVersion, comparedVersion) {
915914 }
916915} ;
917916
917+ assist . verifyRefCursorWithFetchInfo = function ( connection , tableName , array , done ) {
918+ var createProc =
919+ "CREATE OR REPLACE PROCEDURE testproc (p_out OUT SYS_REFCURSOR) " +
920+ "AS " +
921+ "BEGIN " +
922+ " OPEN p_out FOR " +
923+ "SELECT * FROM " + tableName + "; " +
924+ "END; " ;
925+ async . series ( [
926+ function createProcedure ( callback ) {
927+ connection . execute (
928+ createProc ,
929+ function ( err ) {
930+ should . not . exist ( err ) ;
931+ callback ( ) ;
932+ }
933+ ) ;
934+ } ,
935+ function verify ( callback ) {
936+ connection . execute (
937+ "begin testproc(:out); end;" ,
938+ {
939+ out : { type : oracledb . CURSOR , dir : oracledb . BIND_OUT }
940+ } ,
941+ {
942+ outFormat : oracledb . OBJECT ,
943+ fetchInfo :
944+ {
945+ "CONTENT" : { type : oracledb . STRING }
946+ }
947+ } ,
948+ function ( err , result ) {
949+ should . not . exist ( err ) ;
950+ fetchRowsFromRS_fetchas ( connection , result . outBinds . out , array , tableName , callback ) ;
951+ }
952+ ) ;
953+ } ,
954+ function dropProcedure ( callback ) {
955+ connection . execute (
956+ "DROP PROCEDURE testproc" ,
957+ function ( err ) {
958+ should . not . exist ( err ) ;
959+ callback ( ) ;
960+ }
961+ ) ;
962+ }
963+ ] , done ) ;
964+ } ;
965+
966+ assist . verifyRefCursorWithFetchAsString = function ( connection , tableName , array , done ) {
967+ var createProc =
968+ "CREATE OR REPLACE PROCEDURE testproc (p_out OUT SYS_REFCURSOR) " +
969+ "AS " +
970+ "BEGIN " +
971+ " OPEN p_out FOR " +
972+ "SELECT * FROM " + tableName + "; " +
973+ "END; " ;
974+ async . series ( [
975+ function createProcedure ( callback ) {
976+ connection . execute (
977+ createProc ,
978+ function ( err ) {
979+ should . not . exist ( err ) ;
980+ callback ( ) ;
981+ }
982+ ) ;
983+ } ,
984+ function verify ( callback ) {
985+ connection . execute (
986+ "begin testproc(:out); end;" ,
987+ {
988+ out : { type : oracledb . CURSOR , dir : oracledb . BIND_OUT }
989+ } ,
990+ { outFormat : oracledb . OBJECT } ,
991+ function ( err , result ) {
992+ should . not . exist ( err ) ;
993+ fetchRowsFromRS_fetchas ( connection , result . outBinds . out , array , tableName , callback ) ;
994+ }
995+ ) ;
996+ } ,
997+ function dropProcedure ( callback ) {
998+ connection . execute (
999+ "DROP PROCEDURE testproc" ,
1000+ function ( err ) {
1001+ should . not . exist ( err ) ;
1002+ callback ( ) ;
1003+ }
1004+ ) ;
1005+ }
1006+ ] , done ) ;
1007+ } ;
1008+
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 ) {
1021+ should . not . exist ( err ) ;
1022+ cb ( ) ;
1023+ } ) ;
1024+ }
1025+ } ) ;
1026+ }
1027+
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 }
1036+ }
1037+ } ,
1038+ function ( err , result ) {
1039+ should . not . exist ( err ) ;
1040+ rsrows [ i ] . CONTENT . should . eql ( result . rows [ 0 ] [ 0 ] ) ;
1041+ }
1042+ ) ;
1043+ }
1044+
9181045module . exports = assist ;
0 commit comments