FIELD UPDATE()

From Recital Documentation Wiki
Revision as of 16:43, 27 March 2009 by Yvonnemilne (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

PURPOSE

Update a field in the record buffer


SYNONYM

api_field_update()


SYNOPSIS

#include "dbapi.h"
 
int	*FIELD_UPDATE(name, type, string, number, logical, date)
 
<input parameters>
char		*name		/* Address of a buffer containing a field name		*/
char		type;			/* Type of field							*/
char		*string;		/* Address of a buffer containing a character string	*/
double		*number;		/* number								*/
char		logical;		/* T for True and F for False					*/
unsigned long	date;		/* Recital date							*/
DATETIME	datetime;		/* Recital datetime						*/
CURRENCY	currency;		/* Recital currency							*/
 
<output parameters>
none


DESCRIPTION

The FIELD_UPDATE() function will update a specified field in the currently selected database.

If any validation rules have been defined in the Applications Data Dictionary they will be checked first and the field will only be updated if the checks pass. A field can not be updated if it has been defined as calculated in the Applications Data Dictionary.


EXAMPLE

The following example replaces all the fields in the example database with the specified expressions. See Appendix A for the data structure of "example.dbf".

#include "dbapi.h"
 
dbapi_field_update()
{
    int		result;
    double		num;
    char		char[16];
    char		log;
    unsigned long	date;
    DATETIME	datetime;
    CURRENCY	currency;
 
    strcpy(char, "Record Number 3");
    num = 3;
    log = 'T';
    date = DATE_CTOD(DATE_DATE());
    datetime = DATE_STOT(DATE_DATETIME());
    currency = CURR_STOY("7363.93");
 
    if (!DBF_ISEXCLUSIVE()) DBF_LOCKR(DBF_RECNO());
 
    rc=FIELD_UPDATE("blob", 'M', "", &num, log, date, datetime, currency);
    rc=FIELD_UPDATE("byte", 'N', char, &num, log, date, datetime, currency);
    rc=FIELD_UPDATE("char", 'C', char, &num, log, date, datetime, currency);
    rc=FIELD_UPDATE("date", 'D', char, &num, log, date, datetime, currency);
    rc=FIELD_UPDATE("float", 'N', char, &num, log, date, datetime, currency);
    rc=FIELD_UPDATE("int", 'N', char, &num, log, date, datetime, currency);
    rc=FIELD_UPDATE("logical", 'L', char, &num, log, date, datetime, currency);
    rc=FIELD_UPDATE("number", 'N', char, &num, log, date, datetime, currency);
    rc=FIELD_UPDATE("memo", 'M', "", num, log, date, datetime, currency);
    rc=FIELD_UPDATE("real", 'N', char, num, log, date, datetime, currency);
    rc=FIELD_UPDATE("word", 'N', char, num, log, date, datetime, currency);
    rc=FIELD_UPDATE("zoned", 'N', char, num, log, date, datetime, currency);
 
    result = DBF_UPDATE();
 
    if (!DBF_ISEXCLUSIVE()) DBF_UNLOCKR(DBF_RECNO());
 
    _retni( result );
}


SEE ALSO

BLOB_UPDATE(), BLOB_WRITE(), DBF_GATHER(), DBF_READ(), DBF_RECBUFFER(), DBF_UPDATE(), FIELD_COUNT(), FIELD_LOOKUP(), FIELD_NAME(), FIELD_VALUE(), MEMO_UPDATE(), MEMO_WRITE()