Exemplo n.º 1
0
static void
IIdemo_query( II_PTR *connHandle, II_PTR *tranHandle, 
	      char *desc, char *queryText )
{
    IIAPI_QUERYPARM	queryParm;
    IIAPI_GETQINFOPARM	getQInfoParm;
    IIAPI_CLOSEPARM	closeParm;
    IIAPI_WAITPARM	waitParm = { -1 };

    printf( "IIdemo_query: %s\n", desc );

    /*
    ** Call IIapi_query to execute statement.
    */
    queryParm.qy_genParm.gp_callback = NULL;
    queryParm.qy_genParm.gp_closure = NULL;
    queryParm.qy_connHandle = *connHandle;
    queryParm.qy_queryType = IIAPI_QT_QUERY;
    queryParm.qy_queryText = queryText;
    queryParm.qy_parameters = FALSE;
    queryParm.qy_tranHandle = *tranHandle;
    queryParm.qy_stmtHandle = NULL;

    IIapi_query( &queryParm );
  
    while( queryParm.qy_genParm.gp_completed == FALSE )
	IIapi_wait( &waitParm );

    /*
    ** Return transaction handle.
    */
    *tranHandle = queryParm.qy_tranHandle;

    /*
    ** Call IIapi_getQueryInfo() to get results.
    */
    getQInfoParm.gq_genParm.gp_callback = NULL;
    getQInfoParm.gq_genParm.gp_closure = NULL;
    getQInfoParm.gq_stmtHandle = queryParm.qy_stmtHandle;

    IIapi_getQueryInfo( &getQInfoParm );

    while( getQInfoParm.gq_genParm.gp_completed == FALSE )
	IIapi_wait( &waitParm );

    /*
    ** Call IIapi_close() to release resources.
    */
    closeParm.cl_genParm.gp_callback = NULL;
    closeParm.cl_genParm.gp_closure = NULL;
    closeParm.cl_stmtHandle = queryParm.qy_stmtHandle;

    IIapi_close( &closeParm );

    while( closeParm.cl_genParm.gp_completed == FALSE )
	IIapi_wait( &waitParm );

    return;
}
Exemplo n.º 2
0
void
gcd_api_gqi( GCD_PCB *pcb )
{
    pcb->api.name = "IIapi_getQueryInfo()";
    pcb->api.parm.gqi.gq_genParm.gp_callback = gcd_gqi_cmpl;
    pcb->api.parm.gqi.gq_genParm.gp_closure = (PTR)pcb;
    pcb->api.parm.gqi.gq_stmtHandle = pcb->ccb->api.stmt;
    IIapi_getQueryInfo( &pcb->api.parm.gqi );
    return;
}
int OGRIngresStatement::ExecuteSQL( const char *pszStatement )

{
/* -------------------------------------------------------------------- */
/*      Issue the query.                                                */
/* -------------------------------------------------------------------- */
    IIAPI_WAITPARM	waitParm = { -1 };
    IIAPI_QUERYPARM	queryParm;
    II_PTR hTransaction = poTransInfo->GetTransHandle();

    queryParm.qy_genParm.gp_callback = NULL;
    queryParm.qy_genParm.gp_closure = NULL;
    queryParm.qy_connHandle = poTransInfo->GetConnHandle();
    queryParm.qy_queryType = IIAPI_QT_QUERY;
    queryParm.qy_queryText = (II_CHAR *) pszStatement;
    queryParm.qy_parameters = bHaveParm;
    queryParm.qy_tranHandle = hTransaction;
    queryParm.qy_stmtHandle = NULL;

    if( bDebug )
        CPLDebug( "INGRES", "IIapi_query(%s)", pszStatement );

    IIapi_query( &queryParm );
  
/* -------------------------------------------------------------------- */
/*      Capture handles for result.                                     */
/* -------------------------------------------------------------------- */
    while( queryParm.qy_genParm.gp_completed == FALSE )
	IIapi_wait( &waitParm );

    if( queryParm.qy_genParm.gp_status != IIAPI_ST_SUCCESS 
        || poTransInfo->GetConnHandle() == NULL )
    {
        ReportError( &(queryParm.qy_genParm), 
                     CPLString().Printf( "IIapi_query(%s)", pszStatement ) );
        return FALSE;
    }

    hTransaction = queryParm.qy_tranHandle;
    hStmt = queryParm.qy_stmtHandle;
    poTransInfo->SetTransHandle(hTransaction);

    if( hStmt == NULL )						
    {
        CPLDebug( "INGRES", "No resulting statement." );
        return TRUE;
    }

/* -------------------------------------------------------------------- */
/*      Do we have parameters to send?                                  */
/* -------------------------------------------------------------------- */
    if( bHaveParm )
    {
        if( !SendParms() )
            return FALSE;
    }

/* -------------------------------------------------------------------- */
/*      Get description of result columns.                              */
/* -------------------------------------------------------------------- */
    getDescrParm.gd_genParm.gp_callback = NULL;
    getDescrParm.gd_genParm.gp_closure = NULL;
    getDescrParm.gd_stmtHandle = hStmt;
    getDescrParm.gd_descriptorCount = 0;
    getDescrParm.gd_descriptor = NULL;

    IIapi_getDescriptor( &getDescrParm );
    
    while( getDescrParm.gd_genParm.gp_completed == FALSE )
	IIapi_wait( &waitParm );

    if( getDescrParm.gd_genParm.gp_status != IIAPI_ST_SUCCESS )
    {
        if( getDescrParm.gd_genParm.gp_errorHandle )
        {
            if( !bDebug )
                CPLDebug( "INGRES", "IIapi_query(%s)", pszStatement );

            ReportError( &(getDescrParm.gd_genParm), "IIapi_getDescriptor()" );
            return FALSE;
        }
        else
        {
            if( bDebug )
                CPLDebug( "INGRES", "Got gp_status = %d from getDescriptor.",
                          getDescrParm.gd_genParm.gp_status );
        }
    }

/* -------------------------------------------------------------------- */
/*      Get query info.                                                 */
/* -------------------------------------------------------------------- */
#ifdef notdef
    // For reasons I don't understand, calling getQueryInfo seems to screw
    // up access to query results, so this is disabled.
    queryInfo.gq_stmtHandle = hStmt;

    IIapi_getQueryInfo( &queryInfo );

    while( queryInfo.gq_genParm.gp_completed == FALSE )
        IIapi_wait( &waitParm );

    CPLDebug( "INGRES", 
              "gq_flags=%x, gq_mask=%x, gq_rowCount=%d, gq_rowStatus=%d, rowPosition=%d", 
              queryInfo.gq_flags, 
              queryInfo.gq_mask, 
              queryInfo.gq_rowCount, 
              queryInfo.gq_rowStatus, 
              queryInfo.gq_rowPosition ); 
              
    if( queryInfo.gq_genParm.gp_status != IIAPI_ST_SUCCESS )
    {
        ReportError( &(queryInfo.gq_genParm), "IIapi_getQueryInfo()" );
        return FALSE;
    }
#endif

/* -------------------------------------------------------------------- */
/*      Setup buffers for returned rows.                                */
/* -------------------------------------------------------------------- */
    int  i, nBufWidth = 0;

    for( i = 0; i < getDescrParm.gd_descriptorCount; i++ )
        nBufWidth += getDescrParm.gd_descriptor[i].ds_length + 1;

    pabyWrkBuffer = (GByte *) CPLCalloc(1,nBufWidth);

    papszFields = (char **) CPLCalloc(sizeof(char *), 
                                     getDescrParm.gd_descriptorCount+1);

    nBufWidth = 0;
    for( i = 0; i < getDescrParm.gd_descriptorCount; i++ )
    {
        papszFields[i] = (char *) (pabyWrkBuffer + nBufWidth); 
        nBufWidth += getDescrParm.gd_descriptor[i].ds_length + 1;
    }

/* -------------------------------------------------------------------- */
/*      Setup the getColumns() argument.                                */
/* -------------------------------------------------------------------- */
    pasDataBuffer = (IIAPI_DATAVALUE *) 
        CPLCalloc(sizeof(IIAPI_DATAVALUE),getDescrParm.gd_descriptorCount);

    getColParm.gc_genParm.gp_callback = NULL;
    getColParm.gc_genParm.gp_closure = NULL;
    getColParm.gc_rowCount = 1;
    getColParm.gc_columnCount = getDescrParm.gd_descriptorCount;
    getColParm.gc_rowsReturned = 0;
    getColParm.gc_columnData =  pasDataBuffer;
    getColParm.gc_stmtHandle = hStmt;
    getColParm.gc_moreSegments = 0;

    for( i = 0; i < getDescrParm.gd_descriptorCount; i++ )
    {
        getColParm.gc_columnData[i].dv_value = papszFields[i];
    }

/* -------------------------------------------------------------------- */
/*      We don't want papszFields[] pointing to anything but            */
/*      dynamically allocated data for long (blob) fields, so clear     */
/*      these pointers now.                                             */
/* -------------------------------------------------------------------- */
    for( i = 0; i < getDescrParm.gd_descriptorCount; i++ )
    {
        if( IsColumnLong( i ) )
            papszFields[i] = NULL;
    }

    return TRUE;
}
Exemplo n.º 4
0
int
main( int argc, char** argv ) 
{
    II_PTR          	connHandle = (II_PTR)NULL;
    II_PTR        	tranHandle = (II_PTR)NULL;
    II_PTR        	stmtHandle = (II_PTR)NULL;
    II_PTR        	cursorID;
    IIAPI_QUERYPARM	queryParm;
    IIAPI_SETDESCRPARM 	setDescrParm;
    IIAPI_PUTPARMPARM	putParmParm;
    IIAPI_GETDESCRPARM	getDescrParm;
    IIAPI_GETCOLPARM	getColParm;
    IIAPI_GETQINFOPARM  getQInfoParm;
    IIAPI_CLOSEPARM     closeParm;
    IIAPI_WAITPARM      waitParm = { -1 };
    IIAPI_DESCRIPTOR	DescrBuffer[ 1 ];
    IIAPI_DATAVALUE	DataBuffer[ 2 ];
    IIAPI_DATAVALUE	CursorBuffer[ 1 ];
    char                var1[33];  
    int			var2;

    if ( argc != 2 )
    {
	printf( "usage: apiscupd [vnode::]dbname[/server_class]\n" );
	exit( 0 );
    }

    IIdemo_init();
    IIdemo_conn(argv[1],&connHandle);
    IIdemo_query(&connHandle, &tranHandle,"create table",createTBLText);
    IIdemo_query(&connHandle, &tranHandle,"prepare insert",prepText);
    IIdemo_insert(&connHandle,&tranHandle);

    /*
    **  Open cursor.
    */
    printf( "apiscupd: open cursor\n");

    queryParm.qy_genParm.gp_callback = NULL;
    queryParm.qy_genParm.gp_closure = NULL;
    queryParm.qy_connHandle = connHandle;
    queryParm.qy_queryType = IIAPI_QT_OPEN;
    queryParm.qy_queryText = openText;
    queryParm.qy_parameters = FALSE;
    queryParm.qy_tranHandle = tranHandle;
    queryParm.qy_stmtHandle = NULL;

    IIapi_query( &queryParm );

    while( queryParm.qy_genParm.gp_completed == FALSE )
	IIapi_wait( &waitParm );

    tranHandle = queryParm.qy_tranHandle;
    stmtHandle = queryParm.qy_stmtHandle;

    /*
    **  Get cursor row descriptor.
    */
    getDescrParm.gd_genParm.gp_callback = NULL;
    getDescrParm.gd_genParm.gp_closure = NULL;
    getDescrParm.gd_stmtHandle = stmtHandle;
    getDescrParm.gd_descriptorCount = 0;
    getDescrParm.gd_descriptor = NULL;

    IIapi_getDescriptor( &getDescrParm );
    
    while( getDescrParm.gd_genParm.gp_completed == FALSE )
	IIapi_wait( &waitParm );

    /*
    **  Position cursor on row.
    */
    getColParm.gc_genParm.gp_callback = NULL;
    getColParm.gc_genParm.gp_closure = NULL;
    getColParm.gc_rowCount = 1;
    getColParm.gc_columnCount = getDescrParm.gd_descriptorCount;
    getColParm.gc_columnData = DataBuffer;

    getColParm.gc_columnData[0].dv_value = var1;
    getColParm.gc_columnData[1].dv_value = &var2;
    getColParm.gc_stmtHandle = stmtHandle;
    getColParm.gc_moreSegments = 0;

    do
    {
	printf( "apiscupd: next row\n" );
	IIapi_getColumns( &getColParm );
        
        while( getColParm.gc_genParm.gp_completed == FALSE )
	    IIapi_wait( &waitParm );

	if ( getColParm.gc_genParm.gp_status >= IIAPI_ST_NO_DATA )
	    break;

	/*
	**  Update using cursor.
	*/
	printf( "apiscupd: update row\n" );

	queryParm.qy_genParm.gp_callback = NULL;
	queryParm.qy_genParm.gp_closure = NULL;
	queryParm.qy_connHandle = connHandle;
	queryParm.qy_queryType = IIAPI_QT_CURSOR_UPDATE;
	queryParm.qy_queryText = updateText;
	queryParm.qy_parameters = TRUE;
	queryParm.qy_tranHandle = tranHandle;
	queryParm.qy_stmtHandle = NULL;

	IIapi_query( &queryParm );

	while( queryParm.qy_genParm.gp_completed == FALSE )
	    IIapi_wait( &waitParm );

	/*
	**  Describe query parameters - cursor handle.
	*/
	setDescrParm.sd_genParm.gp_callback = NULL;
	setDescrParm.sd_genParm.gp_closure = NULL;
	setDescrParm.sd_stmtHandle = queryParm.qy_stmtHandle;
	setDescrParm.sd_descriptorCount = 1;
	setDescrParm.sd_descriptor = DescrBuffer;

	setDescrParm.sd_descriptor[0].ds_dataType = IIAPI_HNDL_TYPE;
	setDescrParm.sd_descriptor[0].ds_nullable = FALSE;
	setDescrParm.sd_descriptor[0].ds_length = sizeof( II_PTR );
	setDescrParm.sd_descriptor[0].ds_precision = 0;
	setDescrParm.sd_descriptor[0].ds_scale = 0;
	setDescrParm.sd_descriptor[0].ds_columnType = IIAPI_COL_SVCPARM;
	setDescrParm.sd_descriptor[0].ds_columnName = NULL;

	IIapi_setDescriptor( &setDescrParm );

	while( setDescrParm.sd_genParm.gp_completed == FALSE )
	    IIapi_wait( &waitParm );

	/*
	**  Send query parameters - cursor handle.
	*/
	putParmParm.pp_genParm.gp_callback = NULL;
	putParmParm.pp_genParm.gp_closure = NULL;
	putParmParm.pp_stmtHandle = queryParm.qy_stmtHandle;
	putParmParm.pp_parmCount = setDescrParm.sd_descriptorCount;
	putParmParm.pp_parmData = CursorBuffer; 
	putParmParm.pp_moreSegments = 0;

	putParmParm.pp_parmData[0].dv_null = FALSE;
	putParmParm.pp_parmData[0].dv_length = sizeof( II_PTR );
	putParmParm.pp_parmData[0].dv_value = (II_PTR)&cursorID;
	cursorID = stmtHandle;

	IIapi_putParms( &putParmParm );

	while( putParmParm.pp_genParm.gp_completed == FALSE )
	    IIapi_wait( &waitParm );

	/*
	**  Get update statement results.
	*/
	getQInfoParm.gq_genParm.gp_callback = NULL;
	getQInfoParm.gq_genParm.gp_closure = NULL;
	getQInfoParm.gq_stmtHandle = queryParm.qy_stmtHandle;

	IIapi_getQueryInfo( &getQInfoParm );

	while( getQInfoParm.gq_genParm.gp_completed == FALSE )
	    IIapi_wait( &waitParm );

	/*
	**  Free update statement resources.
	*/
	closeParm.cl_genParm.gp_callback = NULL;
	closeParm.cl_genParm.gp_closure = NULL;
	closeParm.cl_stmtHandle = queryParm.qy_stmtHandle;

	IIapi_close( &closeParm );

	while( closeParm.cl_genParm.gp_completed == FALSE )
	   IIapi_wait( &waitParm );

    } while( 1 );

    /*
    **  Get cursor fetch results.
    */
    getQInfoParm.gq_genParm.gp_callback = NULL;
    getQInfoParm.gq_genParm.gp_closure = NULL;
    getQInfoParm.gq_stmtHandle = stmtHandle;

    IIapi_getQueryInfo( &getQInfoParm );

    while( getQInfoParm.gq_genParm.gp_completed == FALSE )
         IIapi_wait( &waitParm );

    /*
    **  Free cursor resources.
    */
    printf( "apiscupd: close cursor\n" );

    closeParm.cl_genParm.gp_callback = NULL;
    closeParm.cl_genParm.gp_closure = NULL;
    closeParm.cl_stmtHandle = stmtHandle;

    IIapi_close( &closeParm );

    while( closeParm.cl_genParm.gp_completed == FALSE )
       IIapi_wait( &waitParm );

    IIdemo_rollback(&tranHandle); 
    IIdemo_disconn(&connHandle);
    IIdemo_term();

    return( 0 );
}
Exemplo n.º 5
0
static 	void
IIdemo_insert( II_PTR *connHandle, II_PTR *tranHandle )
{
    IIAPI_QUERYPARM	queryParm;
    IIAPI_SETDESCRPARM	setDescrParm;
    IIAPI_PUTPARMPARM	putParmParm;
    IIAPI_GETQINFOPARM  getQInfoParm;
    IIAPI_CLOSEPARM	closeParm;
    IIAPI_WAITPARM	waitParm = { -1 };
    IIAPI_DESCRIPTOR	DescrBuffer[ 2 ];
    IIAPI_DATAVALUE	DataBuffer[ 2 ];
    int			row;
    int			i;

    for( row = 0; row < DEMO_TABLE_SIZE; row++ )
    {
	/*
	**  Insert row.
	*/
	printf( "IIdemo_insert: execute insert\n" ); 

	queryParm.qy_connHandle = *connHandle;
	queryParm.qy_queryType = IIAPI_QT_EXEC;
	queryParm.qy_queryText = execText;
	queryParm.qy_parameters = TRUE;
	queryParm.qy_tranHandle = *tranHandle;
	queryParm.qy_stmtHandle = NULL;

	IIapi_query( &queryParm );

        while( queryParm.qy_genParm.gp_completed == FALSE )
	    IIapi_wait( &waitParm );

	*tranHandle =  queryParm.qy_tranHandle;

	/*
	**  Describe query parameters.
	*/
        setDescrParm.sd_genParm.gp_callback = NULL;
      	setDescrParm.sd_genParm.gp_closure = NULL;
  	setDescrParm.sd_stmtHandle = queryParm.qy_stmtHandle;
	setDescrParm.sd_descriptorCount = 2;

        setDescrParm.sd_descriptor = DescrBuffer;
	setDescrParm.sd_descriptor[0].ds_dataType = IIAPI_CHA_TYPE;
	setDescrParm.sd_descriptor[0].ds_nullable = FALSE;
	setDescrParm.sd_descriptor[0].ds_length =
					strlen( insTBLInfo[row].name );
	setDescrParm.sd_descriptor[0].ds_precision = 0;
	setDescrParm.sd_descriptor[0].ds_scale = 0;
	setDescrParm.sd_descriptor[0].ds_columnType = IIAPI_COL_QPARM;
	setDescrParm.sd_descriptor[0].ds_columnName = NULL;

        setDescrParm.sd_descriptor[1].ds_dataType = IIAPI_INT_TYPE;
	setDescrParm.sd_descriptor[1].ds_nullable = FALSE;
        setDescrParm.sd_descriptor[1].ds_length = sizeof( II_INT4 );
        setDescrParm.sd_descriptor[1].ds_precision = 0;
        setDescrParm.sd_descriptor[1].ds_scale = 0;
        setDescrParm.sd_descriptor[1].ds_columnType = IIAPI_COL_QPARM;
        setDescrParm.sd_descriptor[1].ds_columnName = NULL;

 	IIapi_setDescriptor( &setDescrParm );
	
        while( setDescrParm.sd_genParm.gp_completed == FALSE )
	    IIapi_wait( &waitParm );

	/*
	**  Send query parameters.
	*/
	putParmParm.pp_genParm.gp_callback = NULL;
	putParmParm.pp_genParm.gp_closure = NULL;
	putParmParm.pp_stmtHandle = queryParm.qy_stmtHandle;
	putParmParm.pp_parmCount = setDescrParm.sd_descriptorCount;
	putParmParm.pp_moreSegments = 0;

        putParmParm.pp_parmData = DataBuffer;
	putParmParm.pp_parmData[0].dv_null = FALSE;
	putParmParm.pp_parmData[0].dv_length = 
					strlen( insTBLInfo[row].name );
	putParmParm.pp_parmData[0].dv_value = insTBLInfo[row].name;

        putParmParm.pp_parmData[1].dv_null = FALSE;
        putParmParm.pp_parmData[1].dv_length = sizeof( II_INT4 );
        putParmParm.pp_parmData[1].dv_value = &insTBLInfo[row].age;

	IIapi_putParms( &putParmParm );

        while( putParmParm.pp_genParm.gp_completed == FALSE )
	    IIapi_wait( &waitParm );

	/*
	**  Get insert results.
	*/
	getQInfoParm.gq_genParm.gp_callback = NULL;
	getQInfoParm.gq_genParm.gp_closure = NULL;
	getQInfoParm.gq_stmtHandle = queryParm.qy_stmtHandle;

	IIapi_getQueryInfo( &getQInfoParm );

	while( getQInfoParm.gq_genParm.gp_completed == FALSE )
	    IIapi_wait( &waitParm );

	/*
	**  Free statement resources.
	*/
	closeParm.cl_genParm.gp_callback = NULL;
	closeParm.cl_genParm.gp_closure = NULL;
	closeParm.cl_stmtHandle = queryParm.qy_stmtHandle;

	IIapi_close( &closeParm );

	while( closeParm.cl_genParm.gp_completed == FALSE )
	    IIapi_wait( &waitParm );
    }
    
    return;
}
Exemplo n.º 6
0
int
main( int argc, char** argv ) 
{
    II_PTR		connHandle = (II_PTR)NULL;
    II_PTR		tranHandle = (II_PTR)NULL;
    II_PTR		stmtHandle = (II_PTR)NULL;
    II_PTR		envHandle = (II_PTR)NULL;
    IIAPI_CONNPARM	connParm;
    IIAPI_AUTOPARM	autoparm;
    IIAPI_QUERYPARM	queryParm;
    IIAPI_GETDESCRPARM	getDescrParm;
    IIAPI_GETCOLPARM	getColParm;
    IIAPI_GETQINFOPARM	getQInfoParm;
    IIAPI_CLOSEPARM	closeParm;
    IIAPI_WAITPARM	waitParm = { -1 };
    IIAPI_DESCRIPTOR	DescrBuffer[ 5 ];
    IIAPI_DATAVALUE	DataBuffer[ 5 ];
    char		var[5][129];
    short		i, len;

    IIdemo_init(&envHandle);

    /*
    **  Connect to local Name Server
    */
    printf( "apisname: establishing connection to Name Server\n" );

    connParm.co_genParm.gp_callback = NULL;
    connParm.co_genParm.gp_closure = NULL;
    connParm.co_target =  NULL;   
    connParm.co_type   =  IIAPI_CT_NS;   
    connParm.co_connHandle = envHandle; 
    connParm.co_tranHandle = NULL;
    connParm.co_username = NULL;
    connParm.co_password = NULL;
    connParm.co_timeout = -1;

    IIapi_connect( &connParm );
    
    while( connParm.co_genParm.gp_completed == FALSE )
         IIapi_wait( &waitParm );

    connHandle = connParm.co_connHandle;
    tranHandle = connParm.co_tranHandle;
    
    /*
    **  Enable autocommit
    */
    printf( "apisauto: enable autocommit\n" );

    autoparm.ac_genParm.gp_callback = NULL;
    autoparm.ac_genParm.gp_closure  = NULL;
    autoparm.ac_connHandle = connHandle;
    autoparm.ac_tranHandle = NULL;

    IIapi_autocommit( &autoparm );

    while( autoparm.ac_genParm.gp_completed == FALSE )
       IIapi_wait( &waitParm );

    tranHandle = autoparm.ac_tranHandle;

    /*
    **  Execute 'show' statement.
    */
    printf( "apisname: retrieving VNODE connection info\n");

    queryParm.qy_genParm.gp_callback = NULL;
    queryParm.qy_genParm.gp_closure = NULL;
    queryParm.qy_connHandle = connHandle;
    queryParm.qy_queryType = IIAPI_QT_QUERY;
    queryParm.qy_queryText = showText;
    queryParm.qy_parameters = FALSE;
    queryParm.qy_tranHandle = tranHandle;
    queryParm.qy_stmtHandle = NULL;

    IIapi_query( &queryParm );
  
    while( queryParm.qy_genParm.gp_completed == FALSE )
      IIapi_wait( &waitParm );

    stmtHandle = queryParm.qy_stmtHandle;

    /*
    **  Get result row descriptors.
    */
    getDescrParm.gd_genParm.gp_callback = NULL;
    getDescrParm.gd_genParm.gp_closure = NULL;
    getDescrParm.gd_stmtHandle = stmtHandle;
    getDescrParm.gd_descriptorCount = 0;
    getDescrParm.gd_descriptor = NULL; 

    IIapi_getDescriptor( &getDescrParm );
    
    while( getDescrParm.gd_genParm.gp_completed == FALSE )
	IIapi_wait( &waitParm );

    /*
    **  Retrieve result rows.
    */
    getColParm.gc_genParm.gp_callback = NULL;
    getColParm.gc_genParm.gp_closure = NULL;
    getColParm.gc_rowCount = 1;
    getColParm.gc_columnCount = getDescrParm.gd_descriptorCount;
    getColParm.gc_columnData = DataBuffer;
    getColParm.gc_stmtHandle = stmtHandle;
    getColParm.gc_moreSegments = 0;

    for( i = 0; i < getDescrParm.gd_descriptorCount; i++ )
	getColParm.gc_columnData[i].dv_value = var[i]; 

    do 
    {
	IIapi_getColumns( &getColParm );
        
        while( getColParm.gc_genParm.gp_completed == FALSE )
	    IIapi_wait( &waitParm );

	if ( getColParm.gc_genParm.gp_status >= IIAPI_ST_NO_DATA )
	    break; 

        for( i = 0; i < getDescrParm.gd_descriptorCount; i++ ) 
        {
	    if ( getDescrParm.gd_descriptor[i].ds_dataType == IIAPI_VCH_TYPE )
	    {
		memcpy( (char *)&len, var[i], 2 );
		var[i][ len + 2 ] = '\0';
		strcpy( var[i], &var[i][2] );
	    }
	    else
	    {
		var[i][ getColParm.gc_columnData[ i ].dv_length ] = '\0';
	    }

        }

	printf( "\tG/P = %s vnode = %s host = %s prot = %s addr = %s\n", 
		var[0],var[1],var[2],var[3],var[4]);

    } while (1); 

    /*
    **  Get query results.
    */
    getQInfoParm.gq_genParm.gp_callback = NULL;
    getQInfoParm.gq_genParm.gp_closure = NULL;
    getQInfoParm.gq_stmtHandle = stmtHandle;

    IIapi_getQueryInfo( &getQInfoParm );

    while( getQInfoParm.gq_genParm.gp_completed == FALSE )
	IIapi_wait( &waitParm );
          
    /*
    **  Close query.
    */
    closeParm.cl_genParm.gp_callback = NULL;
    closeParm.cl_genParm.gp_closure = NULL;
    closeParm.cl_stmtHandle = stmtHandle;

    IIapi_close( &closeParm );

    while( closeParm.cl_genParm.gp_completed == FALSE )
	IIapi_wait( &waitParm );

    /*
    **  Disable autocommit.
    */
    printf( "apisname: disable autocommit\n" );

    autoparm.ac_connHandle = NULL;
    autoparm.ac_tranHandle = tranHandle;

    IIapi_autocommit( &autoparm );
    
    while( autoparm.ac_genParm.gp_completed == FALSE )
       IIapi_wait( &waitParm );

    IIdemo_disconn(&connHandle);
    IIdemo_term(&envHandle);

    return( 0 );
}