示例#1
0
II_EXTERN II_VOID II_FAR II_EXPORT
IIapi_getDescriptor( IIAPI_GETDESCRPARM II_FAR *getDescrParm )
{
    IIAPI_HNDL	*handle;
    
    IIAPI_TRACE( IIAPI_TR_TRACE )
	( "IIapi_getDescriptor: retrieving columns from server\n" );
    
    /*
    ** Validate Input parameters
    */
    if ( ! getDescrParm )
    {
	IIAPI_TRACE( IIAPI_TR_ERROR )
	    ( "IIapi_getDescriptor: null getDescriptor parameters\n" );
	return;
    }
    
    getDescrParm->gd_genParm.gp_completed = FALSE;
    getDescrParm->gd_genParm.gp_status = IIAPI_ST_SUCCESS;
    getDescrParm->gd_genParm.gp_errorHandle = NULL;
    getDescrParm->gd_descriptorCount = 0;
    getDescrParm->gd_descriptor = NULL;
    handle = (IIAPI_HNDL *)getDescrParm->gd_stmtHandle;
    
    /*
    ** Make sure API is initialized
    */
    if ( ! IIapi_initialized() )
    {
	IIAPI_TRACE( IIAPI_TR_ERROR )
	    ( "IIapi_getDescriptor: API is not initialized\n" );
	IIapi_appCallback( &getDescrParm->gd_genParm, NULL, 
			   IIAPI_ST_NOT_INITIALIZED );
	return;
    }
    
    if ( ( ! IIapi_isStmtHndl( (IIAPI_STMTHNDL *)handle )  &&  
           ! IIapi_isDbevHndl( (IIAPI_DBEVHNDL *)handle ) )  ||
	 IIAPI_STALE_HANDLE( handle ) )
    {
	IIAPI_TRACE( IIAPI_TR_ERROR )
	    ( "IIapi_getDescriptor: invalid handle\n" );
	IIapi_appCallback( &getDescrParm->gd_genParm, NULL, 
			   IIAPI_ST_INVALID_HANDLE );
	return;
    }
    
    IIAPI_TRACE( IIAPI_TR_INFO )
	( "IIapi_getDescriptor: handle = %p\n", handle );
    
    IIapi_clearAllErrors( handle );
    IIapi_uiDispatch( IIAPI_EV_GETDESCR_FUNC, handle, (II_PTR)getDescrParm );

    return;
}
示例#2
0
II_EXTERN II_BOOL
IIapi_validGColCount( IIAPI_STMTHNDL *stmtHndl, IIAPI_GETCOLPARM *getColParm )
{
    II_BOOL		valid;

    if ( IIapi_isDbevHndl( (IIAPI_DBEVHNDL *)stmtHndl ) )
    {
	IIAPI_DBEVHNDL	*dbevHndl = (IIAPI_DBEVHNDL *)stmtHndl;
	IIAPI_DBEVCB	*dbevCB;

	if ( IIapi_isConnHndl( (IIAPI_CONNHNDL *)dbevHndl->eh_parent ) )
	{
	    /*
	    ** This isn't really OK, but the event state
	    ** machine will detect the sequencing error
	    ** and generate the correct message.  If we
	    ** return FALSE here, a misleading error will
	    ** be generated.
	    */
	    valid = TRUE;
	}
	else
	{
	    dbevCB = (IIAPI_DBEVCB *)dbevHndl->eh_parent;

	    /*
	    ** If there is no data, return TRUE so that the
	    ** event state machine can return the NO_DATA
	    ** status.  Otherwise, must be retrieving all
	    ** columns (assumes no BLOBs in event data).
	    ** We don't enforce a single row fetch, but
	    ** the event state machine will only return
	    ** one row.
	    */
	    if ( ! dbevCB->ev_count )
		valid = TRUE;
	    else
		valid = (getColParm->gc_columnCount == dbevCB->ev_count);
	}
    }
    else  if ( getColParm->gc_rowCount > 1 )
    {
	/*
	** When fetching more than one row, must fetch all columns.
	** Watch out for a multi-row request when we are not at the
	** start of a row.
	*/
	valid = ( ! stmtHndl->sh_colIndex  &&
		  getColParm->gc_columnCount == stmtHndl->sh_colCount );
    }
    else
    {
	/*
	** We allow the application to fetch any non-empty subset 
	** of the columns.  Our only restriction is that we do not 
	** span across rows.  If not fetching the entire row, we 
	** will buffer the remainder for subsequent requests.  To 
	** properly fetch a BLOB, it should be the last (or only) 
	** column being fetched.  If this guideline is not
	** followed, we can still operate by discarding all but
	** the first segement of the BLOB (generate a warning)
	** and continue with the rest of the row.
	*/
	valid = ( getColParm->gc_columnCount >= 1  &&
		  (stmtHndl->sh_colIndex + getColParm->gc_columnCount) 
					<= stmtHndl->sh_colCount );
    }

    return( valid );
}