コード例 #1
0
ファイル: KO_ATTR.CPP プロジェクト: AdolphLua/kylin
RETCODE SQL_API SQLSetStmtAttrW ( SQLHSTMT pStmt,
                                  SQLINTEGER pAttr,
                                  SQLPOINTER pDataPtr,
                                  SQLINTEGER pDataSize )

{
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLSetStmtAttrW, Attr: %d, DataPtr: %d, DataSize: %d", pAttr, pDataPtr,
        pDataSize ) );
    __CHK_HANDLE ( pStmt, SQL_HANDLE_STMT, SQL_ERROR );
    _SQLFreeDiag ( _DIAGSTMT ( pStmt ) );

    switch ( pAttr )
    {
        case 1226 : /* MS SQL Server Extension */
        case 1227 :
        case 1228 :
            break;

        case SQL_ATTR_APP_PARAM_DESC :
            __ODBCPOPMSG ( _ODBCPopMsg ( "SQL_ATTR_APP_PARAM_DESC - Cannot set descriptor" ) );
            return SQL_ERROR;

        case SQL_ATTR_APP_ROW_DESC :
            __ODBCPOPMSG ( _ODBCPopMsg ( "SQL_ATTR_APP_ROW_DESC - Cannot set descriptor" ) );
            return SQL_ERROR;

        case SQL_ATTR_ASYNC_ENABLE :
            ( ( pODBCStmt ) pStmt ) -> AsyncEnable = ( ULong ) pDataPtr;
            break;

        case SQL_ATTR_CONCURRENCY :
            ( ( pODBCStmt ) pStmt ) -> Concurrency = ( ULong ) pDataPtr;
            break;

        case SQL_ATTR_CURSOR_SCROLLABLE :
            ( ( pODBCStmt ) pStmt ) -> CursorScroll = ( ULong ) pDataPtr;
            break;

        case SQL_ATTR_CURSOR_SENSITIVITY :
            ( ( pODBCStmt ) pStmt ) -> CursorSensitivity = ( ULong ) pDataPtr;
            break;

        case SQL_ATTR_CURSOR_TYPE :
            ( ( pODBCStmt ) pStmt ) -> CursorType = ( ULong ) pDataPtr;
            break;

        case SQL_ATTR_ENABLE_AUTO_IPD :
            ( ( pODBCStmt ) pStmt ) -> AutoIPD = ( ULong ) pDataPtr;
            break;

        case SQL_ATTR_FETCH_BOOKMARK_PTR :
            __ODBCPOPMSG ( _ODBCPopMsg ( "SQL_ATTR_FETCH_BOOKMARK_PTR - option not implemented" ) );
            return SQL_ERROR;

        case SQL_ATTR_IMP_PARAM_DESC :
            __ODBCPOPMSG ( _ODBCPopMsg ( "SQL_ATTR_IMP_PARAM_DESC - Cannot set descriptor" ) );
            return SQL_ERROR;

        case SQL_ATTR_IMP_ROW_DESC :
            __ODBCPOPMSG ( _ODBCPopMsg ( "SQL_ATTR_IMP_ROW_DESC - Cannot set descriptor" ) );
            return SQL_ERROR;

        case SQL_ATTR_KEYSET_SIZE :
            ( ( pODBCStmt ) pStmt ) -> KeysetSize = ( ULong ) pDataPtr;
            break;

        case SQL_ATTR_MAX_LENGTH :
            __ODBCPOPMSG ( _ODBCPopMsg ( "SQL_ATTR_MAX_LENGTH - option not implemented" ) );
            return SQL_ERROR;

        case SQL_ATTR_MAX_ROWS :
            __ODBCPOPMSG ( _ODBCPopMsg ( "SQL_ATTR_MAX_ROWS - option not implemented" ) );
            return SQL_ERROR;

        case SQL_ATTR_METADATA_ID :
            ( ( pODBCStmt ) pStmt ) -> MetaDataID = ( ULong ) pDataPtr;
            break;

        case SQL_ATTR_NOSCAN :
            ( ( pODBCStmt ) pStmt ) -> NoScan = ( ULong ) pDataPtr;
            break;

        case SQL_ATTR_PARAM_BIND_TYPE :
            _SQLSetAPDField ( & ( ( ( pODBCStmt ) pStmt ) -> APD ), SQL_DESC_BIND_TYPE, pDataPtr, pDataSize );
            break;

        case SQL_ATTR_PARAM_BIND_OFFSET_PTR :
            _SQLSetAPDField ( & ( ( ( pODBCStmt ) pStmt ) -> APD ), SQL_DESC_BIND_OFFSET_PTR, pDataPtr, pDataSize );
            break;

        case SQL_ATTR_PARAM_OPERATION_PTR :
            _SQLSetAPDField ( & ( ( ( pODBCStmt ) pStmt ) -> APD ), SQL_DESC_ARRAY_STATUS_PTR, pDataPtr, pDataSize );
            break;

        case SQL_ATTR_PARAM_STATUS_PTR :
            _SQLSetIPDField ( & ( ( ( pODBCStmt ) pStmt ) -> IPD ), SQL_DESC_ARRAY_STATUS_PTR, pDataPtr, pDataSize );
            break;

        case SQL_ATTR_PARAMS_PROCESSED_PTR :
            // ???? note there is an error in MSDN on SQLSetDescField which says ARD/APD instead of IRD/IPD for this option
            _SQLSetIPDField ( & ( ( ( pODBCStmt ) pStmt ) -> IPD ), SQL_DESC_ROWS_PROCESSED_PTR, pDataPtr, pDataSize );
            break;

        case SQL_ATTR_PARAMSET_SIZE :
            _SQLSetAPDField ( & ( ( ( pODBCStmt ) pStmt ) -> APD ), SQL_DESC_ARRAY_SIZE, pDataPtr, pDataSize );
            break;

        case SQL_ATTR_QUERY_TIMEOUT :
            if ( pDataPtr != NULL )
            {
                ( ( pODBCStmt ) pStmt ) -> QryTimeout = ( ( ULong ) pDataPtr );
            }

            break;

        case SQL_ATTR_RETRIEVE_DATA :
            ( ( pODBCStmt ) pStmt ) -> RetrieveData = ( ULong ) pDataPtr;
            break;

        case SQL_ROWSET_SIZE :
        case SQL_ATTR_ROW_ARRAY_SIZE :
            _SQLSetARDField ( & ( ( ( pODBCStmt ) pStmt ) -> ARD ), SQL_DESC_ARRAY_SIZE, pDataPtr, pDataSize );
            break;

        case SQL_ATTR_ROW_BIND_OFFSET_PTR :
            _SQLSetARDField ( & ( ( ( pODBCStmt ) pStmt ) -> ARD ), SQL_DESC_BIND_OFFSET_PTR, pDataPtr, pDataSize );
            break;

        case SQL_ATTR_ROW_BIND_TYPE :
            _SQLSetARDField ( & ( ( ( pODBCStmt ) pStmt ) -> ARD ), SQL_DESC_BIND_TYPE, pDataPtr, pDataSize );
            break;

        case SQL_ATTR_ROW_OPERATION_PTR :
            _SQLSetARDField ( & ( ( ( pODBCStmt ) pStmt ) -> ARD ), SQL_DESC_ARRAY_STATUS_PTR, pDataPtr, pDataSize );
            break;

        case SQL_ATTR_ROW_STATUS_PTR :
            _SQLSetIRDField ( & ( ( ( pODBCStmt ) pStmt ) -> IRD ), SQL_DESC_ARRAY_STATUS_PTR, pDataPtr, pDataSize );
            break;

        case SQL_ATTR_ROWS_FETCHED_PTR :
            _SQLSetIRDField ( & ( ( ( pODBCStmt ) pStmt ) -> IRD ), SQL_DESC_ROWS_PROCESSED_PTR, pDataPtr, pDataSize );
            break;

        case SQL_ATTR_SIMULATE_CURSOR :
            __ODBCPOPMSG ( _ODBCPopMsg ( "SQL_ATTR_SIMULATE_CURSOR - option not implemented" ) );
            return SQL_ERROR;

        default :
            __ODBCPOPMSG ( _ODBCPopMsg ( "SQLSetStmtAttrW : Stmt attr - unknown %d", pAttr ) );
            return SQL_ERROR;
    }

    return SQL_SUCCESS;
}
コード例 #2
0
ファイル: KO_ATTR.CPP プロジェクト: KylinOLAP/odbc-driver
RETCODE SQL_API SQLGetStmtAttr ( SQLHSTMT    pStmt,
                                 SQLINTEGER  pAttr,
                                 SQLPOINTER  pDataPtr,
                                 SQLINTEGER  pDataSize,
                                 SQLINTEGER* pDataSizePtr ) {
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLGetStmtAttr, Attr: %d, DataPtr: %d, DataSize: %d", pAttr, pDataPtr,
                              pDataSize ) );
    __CHK_HANDLE ( pStmt, SQL_HANDLE_STMT, SQL_ERROR );
    _SQLFreeDiag ( _DIAGSTMT ( pStmt ) );
    
    switch ( pAttr ) {
        case SQL_ATTR_APP_PARAM_DESC:
            * ( ( Long* ) pDataPtr ) = ( Long ) & ( ( ( pODBCStmt ) pStmt )->APD );
            break;
            
        case SQL_ATTR_APP_ROW_DESC:
            * ( ( Long* ) pDataPtr ) = ( Long ) & ( ( ( pODBCStmt ) pStmt )->ARD );
            break;
            
        case SQL_ATTR_ASYNC_ENABLE:
            * ( ( ULong* ) pDataPtr ) = ( ( pODBCStmt ) pStmt )->AsyncEnable;
            break;
            
        case SQL_ATTR_CONCURRENCY:
            * ( ( ULong* ) pDataPtr ) = ( ( pODBCStmt ) pStmt )->Concurrency;
            break;
            
        case SQL_ATTR_CURSOR_SCROLLABLE:
            * ( ( ULong* ) pDataPtr ) = ( ( pODBCStmt ) pStmt )->CursorScroll;
            break;
            
        case SQL_ATTR_CURSOR_SENSITIVITY:
            * ( ( ULong* ) pDataPtr ) = ( ( pODBCStmt ) pStmt )->CursorSensitivity;
            break;
            
        case SQL_ATTR_CURSOR_TYPE:
            * ( ( ULong* ) pDataPtr ) = ( ( pODBCStmt ) pStmt )->CursorType;
            break;
            
        case SQL_ATTR_ENABLE_AUTO_IPD:
            * ( ( ULong* ) pDataPtr ) = ( ( pODBCStmt ) pStmt )->AutoIPD;
            break;
            
        case SQL_ATTR_FETCH_BOOKMARK_PTR:
            __ODBCPOPMSG ( _ODBCPopMsg ( "SQL_ATTR_FETCH_BOOKMARK_PTR - option not implemented" ) );
            return SQL_ERROR;
            
        case SQL_ATTR_IMP_PARAM_DESC:
            * ( ( Long* ) pDataPtr ) = ( Long ) & ( ( ( pODBCStmt ) pStmt )->IPD );
            break;
            
        case SQL_ATTR_IMP_ROW_DESC:
            * ( ( Long* ) pDataPtr ) = ( Long ) & ( ( ( pODBCStmt ) pStmt )->IRD );
            break;
            
        case SQL_ATTR_KEYSET_SIZE:
            * ( ( Long* ) pDataPtr ) = ( ( pODBCStmt ) pStmt )->KeysetSize;
            break;
            
        case SQL_ATTR_MAX_LENGTH:
            * ( ( ULong* ) pDataPtr ) = 0;
            __ODBCPOPMSG ( _ODBCPopMsg ( "SQL_ATTR_MAX_LENGTH - option not implemented" ) );
            return SQL_ERROR;
            
        case SQL_ATTR_MAX_ROWS:
            * ( ( ULong* ) pDataPtr ) = 0;
            __ODBCPOPMSG ( _ODBCPopMsg ( "SQL_ATTR_MAX_ROWS - option not implemented" ) );
            return SQL_ERROR;
            
        case SQL_ATTR_METADATA_ID:
            * ( ( ULong* ) pDataPtr ) = ( ( pODBCStmt ) pStmt )->MetaDataID;
            break;
            
        case SQL_ATTR_NOSCAN:
            * ( ( ULong* ) pDataPtr ) = ( ( pODBCStmt ) pStmt )->NoScan;
            break;
            
        case SQL_ATTR_PARAM_BIND_TYPE:
            _SQLGetAPDField ( & ( ( ( pODBCStmt ) pStmt )->APD ), SQL_DESC_BIND_TYPE, pDataPtr, pDataSize, pDataSizePtr );
            break;
            
        case SQL_ATTR_PARAM_BIND_OFFSET_PTR:
            _SQLGetAPDField ( & ( ( ( pODBCStmt ) pStmt )->APD ), SQL_DESC_BIND_OFFSET_PTR, pDataPtr, pDataSize, pDataSizePtr );
            break;
            
        case SQL_ATTR_PARAM_OPERATION_PTR:
            _SQLGetAPDField ( & ( ( ( pODBCStmt ) pStmt )->APD ), SQL_DESC_ARRAY_STATUS_PTR, pDataPtr, pDataSize, pDataSizePtr );
            break;
            
        case SQL_ATTR_PARAM_STATUS_PTR:
            _SQLGetIPDField ( & ( ( ( pODBCStmt ) pStmt )->IPD ), SQL_DESC_ARRAY_STATUS_PTR, pDataPtr, pDataSize, pDataSizePtr );
            break;
            
        case SQL_ATTR_PARAMS_PROCESSED_PTR:
            // ???? note there is an error in MSDN on SQLSetDescField which says ARD/APD instead of IRD/IPD for this option
            _SQLGetAPDField ( & ( ( ( pODBCStmt ) pStmt )->APD ), SQL_DESC_ROWS_PROCESSED_PTR, pDataPtr, pDataSize,
                              pDataSizePtr );
            break;
            
        case SQL_ATTR_PARAMSET_SIZE:
            _SQLGetAPDField ( & ( ( ( pODBCStmt ) pStmt )->APD ), SQL_DESC_ARRAY_SIZE, pDataPtr, pDataSize, pDataSizePtr );
            break;
            
        case SQL_ATTR_QUERY_TIMEOUT:
            * ( ( ULong* ) pDataPtr ) = ( ( pODBCStmt ) pStmt )->QryTimeout;
            break;
            
        case SQL_ATTR_RETRIEVE_DATA:
            * ( ( ULong* ) pDataPtr ) = ( ( pODBCStmt ) pStmt )->RetrieveData;
            break;
            
        case SQL_ROWSET_SIZE:
        case SQL_ATTR_ROW_ARRAY_SIZE:
            _SQLGetARDField ( & ( ( ( pODBCStmt ) pStmt )->ARD ), SQL_DESC_ARRAY_SIZE, pDataPtr, pDataSize, pDataSizePtr );
            break;
            
        case SQL_ATTR_ROW_BIND_OFFSET_PTR:
            _SQLGetARDField ( & ( ( ( pODBCStmt ) pStmt )->ARD ), SQL_DESC_BIND_OFFSET_PTR, pDataPtr, pDataSize, pDataSizePtr );
            break;
            
        case SQL_ATTR_ROW_BIND_TYPE:
            _SQLGetARDField ( & ( ( ( pODBCStmt ) pStmt )->ARD ), SQL_DESC_BIND_TYPE, pDataPtr, pDataSize, pDataSizePtr );
            break;
            
        case SQL_ATTR_ROW_NUMBER:
            // ??? in case of rowset being > 1, start row is being returned
            * ( ( ULong* ) pDataPtr ) = ( ( pODBCStmt ) pStmt )->CurRowsetStartRowPos;
            break;
            
        case SQL_ATTR_ROW_OPERATION_PTR:
            _SQLGetARDField ( & ( ( ( pODBCStmt ) pStmt )->ARD ), SQL_DESC_ARRAY_STATUS_PTR, pDataPtr, pDataSize, pDataSizePtr );
            break;
            
        case SQL_ATTR_ROW_STATUS_PTR:
            _SQLGetIRDField ( & ( ( ( pODBCStmt ) pStmt )->IRD ), SQL_DESC_ARRAY_STATUS_PTR, pDataPtr, pDataSize, pDataSizePtr );
            break;
            
        case SQL_ATTR_ROWS_FETCHED_PTR:
            _SQLGetIRDField ( & ( ( ( pODBCStmt ) pStmt )->IRD ), SQL_DESC_ROWS_PROCESSED_PTR, pDataPtr, pDataSize,
                              pDataSizePtr );
            break;
            
        case SQL_ATTR_SIMULATE_CURSOR:
            __ODBCPOPMSG ( _ODBCPopMsg ( "SQL_ATTR_SIMULATE_CURSOR - option not implemented" ) );
            return SQL_ERROR;
            
        default:
            __ODBCPOPMSG ( _ODBCPopMsg ( "SQLGetStmtAttr: Stmt attr - unknown %d", pAttr ) );
            return SQL_ERROR;
    }
    
    return SQL_SUCCESS;
}