📄 ogrocisession.cpp
字号:
CPLError( CE_Failure, CPLE_AppDefined, "%s in %s", szErrorMsg, pszFunction ); return TRUE; } else if( nStatus == OCI_NEED_DATA ) { CPLError( CE_Failure, CPLE_AppDefined, "OCI_NEED_DATA" ); return TRUE; } else if( nStatus == OCI_INVALID_HANDLE ) { CPLError( CE_Failure, CPLE_AppDefined, "OCI_INVALID_HANDLE in %s", pszFunction ); return TRUE; } else if( nStatus == OCI_STILL_EXECUTING ) { CPLError( CE_Failure, CPLE_AppDefined, "OCI_STILL_EXECUTING in %s", pszFunction ); return TRUE; } else if( nStatus == OCI_CONTINUE ) { CPLError( CE_Failure, CPLE_AppDefined, "OCI_CONTINUE in %s", pszFunction ); return TRUE; } else return FALSE;}/************************************************************************//* GetParmInfo() *//************************************************************************/CPLErr OGROCISession::GetParmInfo( OCIParam *hParmDesc, OGRFieldDefn *poOGRDefn, ub2 *pnOCIType, ub4 *pnOCILen ){ ub2 nOCIType, nOCILen; ub4 nColLen; char *pszColName; char szTermColName[128]; /* -------------------------------------------------------------------- *//* Get basic parameter details. *//* -------------------------------------------------------------------- */ if( Failed( OCIAttrGet( hParmDesc, OCI_DTYPE_PARAM, (dvoid **)&nOCIType, 0, OCI_ATTR_DATA_TYPE, hError ), "OCIAttrGet(Type)" ) ) return CE_Failure; if( Failed( OCIAttrGet( hParmDesc, OCI_DTYPE_PARAM, (dvoid **)&nOCILen, 0, OCI_ATTR_DATA_SIZE, hError ), "OCIAttrGet(Size)" ) ) return CE_Failure; if( Failed( OCIAttrGet( hParmDesc, OCI_DTYPE_PARAM, (dvoid **)&pszColName, &nColLen, OCI_ATTR_NAME, hError ), "OCIAttrGet(Name)") ) return CE_Failure; if( nColLen >= sizeof(szTermColName) ) { CPLError( CE_Failure, CPLE_AppDefined, "Column length (%d) longer than column name buffer (%d) in\n" "OGROCISession::GetParmInfo()", nColLen, sizeof(szTermColName) ); return CE_Failure; } strncpy( szTermColName, pszColName, nColLen ); szTermColName[nColLen] = '\0'; poOGRDefn->SetName( szTermColName );/* -------------------------------------------------------------------- *//* Attempt to classify as an OGRType. *//* -------------------------------------------------------------------- */ switch( nOCIType ) { case SQLT_CHR: case SQLT_AFC: /* CHAR(), NCHAR() */ poOGRDefn->SetType( OFTString ); if( nOCILen < 2048 ) poOGRDefn->SetWidth( nOCILen ); break; case SQLT_NUM: { // NOTE: OCI docs say this should be ub1 type, but we have // determined that oracle is actually returning a short so we // use that type and try to compensate for possible problems by // initializing, and dividing by 256 if it is large. unsigned short byPrecision = 0; sb1 nScale; if( Failed( OCIAttrGet( hParmDesc, OCI_DTYPE_PARAM, (dvoid **)&byPrecision, 0, OCI_ATTR_PRECISION, hError ), "OCIAttrGet(Precision)" ) ) return CE_Failure; if( Failed( OCIAttrGet( hParmDesc, OCI_DTYPE_PARAM, (dvoid **)&nScale, 0, OCI_ATTR_SCALE, hError ), "OCIAttrGet(Scale)") ) return CE_Failure;#ifdef notdef CPLDebug( "OCI", "%s: Scale=%d, Precision=%d", szTermColName, nScale, byPrecision );#endif if( byPrecision > 255 ) byPrecision = byPrecision / 256; if( nScale < 0 ) poOGRDefn->SetType( OFTReal ); else if( nScale > 0 ) { poOGRDefn->SetType( OFTReal ); poOGRDefn->SetWidth( byPrecision ); poOGRDefn->SetPrecision( nScale ); } else if( byPrecision < 38 ) { poOGRDefn->SetType( OFTInteger ); poOGRDefn->SetWidth( byPrecision ); } else { poOGRDefn->SetType( OFTInteger ); } } break; case SQLT_DATE: poOGRDefn->SetType( OFTString ); poOGRDefn->SetWidth( 24 ); break; case SQLT_RID: case SQLT_BIN: case SQLT_LBI: case 111: /* REF */ case SQLT_CLOB: case SQLT_BLOB: case SQLT_FILE: case 208: /* UROWID */ poOGRDefn->SetType( OFTBinary ); break; default: poOGRDefn->SetType( OFTBinary ); break; } if( pnOCIType != NULL ) *pnOCIType = nOCIType; if( pnOCILen != NULL ) *pnOCILen = nOCILen; return CE_None;}/************************************************************************//* CleanName() *//* *//* Modify a name in-place to be a well formed Oracle name. *//************************************************************************/void OGROCISession::CleanName( char * pszName ){ int i; if( strlen(pszName) > 30 ) pszName[30] = '\0'; for( i = 0; pszName[i] != '\0'; i++ ) { pszName[i] = toupper(pszName[i]); if( (pszName[i] < '0' || pszName[i] > '9') && (pszName[i] < 'A' || pszName[i] > 'Z') && pszName[i] != '_' ) pszName[i] = '_'; }}/************************************************************************//* PinTDO() *//* *//* Fetch a Type Description Object for the named type. *//************************************************************************/OCIType *OGROCISession::PinTDO( const char *pszType ){ OCIParam *hGeomParam = NULL; OCIRef *hGeomTypeRef = NULL; OCIType *hPinnedTDO = NULL; if( Failed( OCIDescribeAny(hSvcCtx, hError, (text *) pszType, (ub4) strlen(pszType), OCI_OTYPE_NAME, (ub1)1, (ub1)OCI_PTYPE_TYPE, hDescribe ), "GetTDO()->OCIDescribeAny()" ) ) return NULL; if( Failed( OCIAttrGet((dvoid *)hDescribe, (ub4)OCI_HTYPE_DESCRIBE, (dvoid *)&hGeomParam, (ub4 *)0, (ub4)OCI_ATTR_PARAM, hError), "GetTDO()->OCIGetAttr(ATTR_PARAM)") ) return NULL; if( Failed( OCIAttrGet((dvoid *)hGeomParam, (ub4)OCI_DTYPE_PARAM, (dvoid *)&hGeomTypeRef, (ub4 *)0, (ub4)OCI_ATTR_REF_TDO, hError), "GetTDO()->OCIAttrGet(ATTR_REF_TDO)" ) ) return NULL; if( Failed( OCIObjectPin(hEnv, hError, hGeomTypeRef, (OCIComplexObject *)0, OCI_PIN_ANY, OCI_DURATION_SESSION, OCI_LOCK_NONE, (dvoid **)&hPinnedTDO ), "GetTDO()->OCIObjectPin()" ) ) return NULL; return hPinnedTDO;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -