Exemple #1
0
/*{
** Name:	IIAG4get_data   copy data to program variables
**
** Description:
**	Copy data from a DB_DATA_VALUE to the user's program variables.
**	If the data is an object, we put it into the bag of known objects, 
**	and give the user the bag's index.
**
** Inputs:
**	dbdv		DB_DATA_VALUE *	Data to put
**      type            i4              ADF type of user variable
**      length          i4              data size of user variable
**
** Outputs:
**      ind             i2 *            NULL indicator
**      data            PTR             user variable pointer
**
**	Returns:
**		STATUS
**					OK
**					E_G4271B_DATA_CONVERSION_GET
**					E_G4271A_NO_NULL_INDICATOR
**
** History:
**	15-dec-92 (davel)
**		 Initial version, based on W4GL version developed by MikeS.
*/
STATUS
IIAG4get_data(DB_DATA_VALUE *dbdv, i2 *ind, i4  type, i4  length, PTR data)
{
    STATUS status = OK;
    DB_DATA_VALUE int_dbdv;
    DB_EMBEDDED_DATA edv;
    i4 objno;
    ADF_CB *cb = FEadfcb();

    /* 
    ** See if the data is an object
    */
    if (dbdv->db_datatype == DB_DMY_TYPE)
    {
	/* Yes.  Make an i4 DBDV */
	int_dbdv.db_datatype = DB_INT_TYPE;
	int_dbdv.db_length = sizeof(i4);
	int_dbdv.db_prec = 0;
	int_dbdv.db_data = (PTR)&objno;

	if ( (status = IIAG4aoAddObject(dbdv->db_data, &objno) ) != OK )
	{
	    /* convert any IIAG4aoAddObject error to the generic
	    ** E_G42729_GETDATA_ERROR, as IIAG4aoAddObject already raised
	    ** the specific error.
	    */
	    return E_G42729_GETDATA_ERROR;
	}
	dbdv = &int_dbdv;
    }

    /* Return the data */
    edv.ed_type = type;
    edv.ed_length = length;
    edv.ed_data = data;
    edv.ed_null = ind;

    if (adh_dbcvtev(cb, dbdv, &edv) != OK)
    {
	if (cb->adf_errcb.ad_errcode == E_AD1012_NULL_TO_NONNULL)
	    status = E_G4271A_NO_NULL_INDICATOR;
	else
	    status = E_G4271B_DATA_CONVERSION_GET;
    }

    return status;
}
Exemple #2
0
i4
IIgetfldio(i2 *ind, i4 variable, i4 type, i4 len, PTR data, char *name)
{
	char			*namestr;
	char			fbuf[MAXFRSNAME+1];
	DB_EMBEDDED_DATA	edv;
	DB_DATA_VALUE		*dbvptr;
	DB_DATA_VALUE		oper_dbv;
	DB_DATA_VALUE		dbvcop;
	i4			oper;
	ADF_CB			*cb;
	bool			errflag = FALSE;
	i4			getop = 0;
	i4			(*oldproc)();
	bool			disp_msgs = TRUE;

	/*	Check field name for validity  */

	namestr = IIstrconv(II_CONV, name, fbuf, (i4)MAXFRSNAME);
	if (namestr == NULL)
	{
		IIFDerror(RTRFFL, 2, IIfrmio->fdfrmnm, ERx(""));
		return(FALSE);
	}

	/*  Set up an EDV to describe the caller's parameters.  */

	edv.ed_type = type;
	edv.ed_length = len;
	edv.ed_data = (PTR) data;
	edv.ed_null = ind;
	
	cb = FEadfcb();

	if (IIfrscb->frs_globs->enabled & GETMSGS_OFF)
	{
	    disp_msgs = FALSE;
	    oldproc = IIseterr(IIFRgmoGetmsgsOff);
	}

	/*
	**  If getting an 'oper', not a value, special processing required.
	**  Operators are not returned from FRAME as DBV's, so we must build
	**  one so we can follow the normal path and convert to the final EDV.
	*/

	getop = IIgetoper( (i4) 0 );

	if ( getop )
	{
		oper_dbv.db_datatype = DB_INT_TYPE;
		oper_dbv.db_length = sizeof(i4);
		oper_dbv.db_prec = 0;
		oper_dbv.db_data = (PTR) &oper;

		/*
		** Make sure the frame is in Query mode, else return NOOP.
		*/
		if (IIfrmio->fdrunmd != fdrtQRY)
			oper = fdNOP;
		else
			FDqryop( IIfrmio->fdrunfrm, namestr, (i4 *)
				oper_dbv.db_data );

		dbvptr = &oper_dbv;
	}
	else if (IIfrmio->fdrunmd == fdrtQRY)
	{
		/*
		**	If in query mode, we must use a different routine
		**	to retrieve the data portion of the field.  This
		**	routine also strips off the operator.
		*/

		if (!FDqryfld(IIfrmio->fdrunfrm, namestr, &dbvptr))
			errflag = TRUE;
	}
	else
	{
		IIfrscb->frs_event->eval_aggs = TRUE;

		/*
		**	Get data portion of the field
		*/

		if (!FDgetfld(IIfrmio->fdrunfrm, namestr, &dbvptr))
			errflag = TRUE;

		IIfrscb->frs_event->eval_aggs = FALSE;
	}

	/*
	**  If "errflag" is set at this point, then it was not
	**  possible to get the DB_DATA_VALUE pointer for a field.
	**
	**  Trim trailing blanks on character-type fields
	*/
	if ( errflag == FALSE && ( IIftrim( dbvptr, &dbvcop ) != OK ) )
		errflag = TRUE;

	/*
	**  Convert the DBV containing the field's value to an EDV
	*/

	if ( errflag == FALSE && ( adh_dbcvtev( cb, &dbvcop, &edv ) != OK ) )
	{
		if (cb->adf_errcb.ad_errcode == E_AD1012_NULL_TO_NONNULL)
		{
			IIFDerror(RTRNLNNL, 2, IIfrmio->fdfrmnm, namestr);
		}
		else
		{
			IIFDerror(RTGFERR, 2, IIfrmio->fdfrmnm, namestr);
		}
		errflag = TRUE;
	}

	if (!disp_msgs)
	    _VOID_ IIseterr(oldproc);

	if ( errflag == TRUE )
		return (FALSE);
	else
		return (TRUE);
}