1- // Copyright (c) 2015, 2019 , Oracle and/or its affiliates. All rights reserved.
1+ // Copyright (c) 2015, 2020 , Oracle and/or its affiliates. All rights reserved.
22
33//-----------------------------------------------------------------------------
44//
@@ -463,14 +463,12 @@ static napi_value njsConnection_createLob(napi_env env,
463463static bool njsConnection_createLobAsync (njsBaton * baton )
464464{
465465 njsConnection * conn = (njsConnection * ) baton -> callingInstance ;
466- dpiOracleTypeNum typeNum ;
467466
468- typeNum = (baton -> lobType == NJS_DATATYPE_CLOB ) ? DPI_ORACLE_TYPE_CLOB :
469- DPI_ORACLE_TYPE_BLOB ;
470467 baton -> lob = calloc (1 , sizeof (njsLobBuffer ));
471468 if (!baton -> lob )
472469 return njsBaton_setError (baton , errInsufficientMemory );
473- if (dpiConn_newTempLob (conn -> handle , typeNum , & baton -> lob -> handle ) < 0 )
470+ if (dpiConn_newTempLob (conn -> handle , baton -> lobType ,
471+ & baton -> lob -> handle ) < 0 )
474472 return njsBaton_setErrorDPI (baton );
475473 baton -> lob -> dataType = baton -> lobType ;
476474 if (!njsLob_populateBuffer (baton , baton -> lob ))
@@ -503,11 +501,10 @@ static bool njsConnection_createLobProcessArgs(njsBaton *baton,
503501{
504502 if (!njsUtils_getUnsignedIntArg (env , args , 0 , & baton -> lobType ))
505503 return false;
506- if (baton -> lobType != NJS_DATATYPE_CLOB &&
507- baton -> lobType != NJS_DATATYPE_BLOB ) {
508- njsUtils_throwError (env , errInvalidParameterValue , 1 );
509- return false;
510- }
504+ if (baton -> lobType != DPI_ORACLE_TYPE_CLOB &&
505+ baton -> lobType != DPI_ORACLE_TYPE_BLOB &&
506+ baton -> lobType != DPI_ORACLE_TYPE_NCLOB )
507+ return njsUtils_throwError (env , errInvalidParameterValue , 1 );
511508
512509 return true;
513510}
@@ -2309,17 +2306,17 @@ static bool njsConnection_scanExecuteBinds(njsBaton *baton, napi_env env,
23092306 }
23102307
23112308 // get bind information from value if it has not already been specified
2312- if (var -> bindDataType == NJS_DATATYPE_DEFAULT || !var -> maxSize ||
2309+ if (var -> varTypeNum == NJS_DATATYPE_DEFAULT || !var -> maxSize ||
23132310 var -> maxSize == NJS_MAX_OUT_BIND_SIZE ) {
2314- defaultBindType = var -> bindDataType ;
2311+ defaultBindType = var -> varTypeNum ;
23152312 defaultMaxSize = var -> maxSize ;
23162313 defaultObjectTypeHandle = var -> dpiObjectTypeHandle ;
23172314 if (!njsConnection_getBindInfoFromValue (baton , false, env ,
23182315 bindValue , & defaultBindType , & defaultMaxSize ,
23192316 & defaultObjectTypeHandle ))
23202317 return false;
2321- if (var -> bindDataType == NJS_DATATYPE_DEFAULT )
2322- var -> bindDataType = defaultBindType ;
2318+ if (var -> varTypeNum == NJS_DATATYPE_DEFAULT )
2319+ var -> varTypeNum = defaultBindType ;
23232320 if (defaultMaxSize > var -> maxSize )
23242321 var -> maxSize = defaultMaxSize ;
23252322 if (!var -> dpiObjectTypeHandle && defaultObjectTypeHandle )
@@ -2331,7 +2328,7 @@ static bool njsConnection_scanExecuteBinds(njsBaton *baton, napi_env env,
23312328 // specified by the application; for OUT binds, the value from the
23322329 // application must be accepted as is as there is no way to
23332330 // validate it
2334- if (var -> bindDataType != NJS_DATATYPE_OBJECT ) {
2331+ if (var -> varTypeNum != DPI_ORACLE_TYPE_OBJECT ) {
23352332
23362333 NJS_CHECK_NAPI (env , napi_is_array (env , bindValue , & check ))
23372334 if (check ) {
@@ -2415,7 +2412,7 @@ static bool njsConnection_scanExecuteBindUnit(njsBaton *baton,
24152412 if (!njsDbObjectType_getFromClass (env , value , & var -> objectType ))
24162413 return false;
24172414 var -> dpiObjectTypeHandle = var -> objectType -> handle ;
2418- var -> bindDataType = NJS_DATATYPE_OBJECT ;
2415+ var -> varTypeNum = DPI_ORACLE_TYPE_OBJECT ;
24192416 okBindUnit = true;
24202417 } else if (valueType == napi_string ) {
24212418
@@ -2447,11 +2444,11 @@ static bool njsConnection_scanExecuteBindUnit(njsBaton *baton,
24472444 dpiObjectType_release (objTypeHandle );
24482445 }
24492446 var -> dpiObjectTypeHandle = var -> objectType -> handle ;
2450- var -> bindDataType = NJS_DATATYPE_OBJECT ;
2447+ var -> varTypeNum = DPI_ORACLE_TYPE_OBJECT ;
24512448 okBindUnit = true;
24522449 } else {
24532450 if (!njsBaton_getUnsignedIntFromArg (baton , env , args , 1 , "type" ,
2454- & var -> bindDataType , & found ))
2451+ & var -> varTypeNum , & found ))
24552452 return false;
24562453 if (found ) {
24572454 okBindUnit = true;
@@ -2474,8 +2471,8 @@ static bool njsConnection_scanExecuteBindUnit(njsBaton *baton,
24742471 if (found ) {
24752472 okBindUnit = true;
24762473 } else if (inExecuteMany ) {
2477- if (var -> bindDataType == NJS_DATATYPE_STR ||
2478- var -> bindDataType == NJS_DATATYPE_BUFFER ) {
2474+ if (var -> varTypeNum == DPI_ORACLE_TYPE_VARCHAR ||
2475+ var -> varTypeNum == DPI_ORACLE_TYPE_RAW ) {
24792476 if (var -> pos > 0 )
24802477 return njsBaton_setError (baton , errMissingMaxSizeByPos ,
24812478 var -> pos );
@@ -2557,15 +2554,15 @@ static bool njsConnection_scanExecuteManyBinds(njsBaton *baton,
25572554 continue ;
25582555
25592556 // otherwise, determine bind type and size by examining the value
2560- defaultBindType = var -> bindDataType ;
2557+ defaultBindType = var -> varTypeNum ;
25612558 defaultMaxSize = var -> maxSize ;
25622559 defaultObjectTypeHandle = var -> dpiObjectTypeHandle ;
25632560 if (!njsConnection_getBindInfoFromValue (baton , true, env ,
25642561 value , & defaultBindType , & defaultMaxSize ,
25652562 & defaultObjectTypeHandle ))
25662563 return false;
2567- if (var -> bindDataType == NJS_DATATYPE_DEFAULT )
2568- var -> bindDataType = defaultBindType ;
2564+ if (var -> varTypeNum == NJS_DATATYPE_DEFAULT )
2565+ var -> varTypeNum = defaultBindType ;
25692566 if (defaultMaxSize > var -> maxSize )
25702567 var -> maxSize = defaultMaxSize ;
25712568 if (!var -> dpiObjectTypeHandle && defaultObjectTypeHandle )
0 commit comments