FIELD LOOKUP()

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

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

PURPOSE

Return field information


SYNONYM

api_field_lookup()


SYNOPSIS

#include "dbapi.h"
 
struct API_FIELD	FIELD_LOOKUP(fldname, fldinfo)
 
<input parameters>
char			*fldname;		/* Address of a buffer containing a field name		*/
 
<output parameters>
struct API_FIELD	*fldinfo;		/* Address of a buffer containing field information	*/


DESCRIPTION

The FIELD_LOOKUP() function will return information for the specified field in the currently selected database.

Field protections defined in the Applications Data Dictionary are checked first and if the field is hidden a NULL value is returned.

The field information is stored in the API_FIELD data structure defined below.

Struct	API_FIELD {
    int	fieldno;		/* Field number					*/
    char	type;			/* Datatype of field				*/
    int	size;			/* Storage size in the record			*/
    int	width;		/* Display width					*/
    int	decimal;		/* Decimal places for numerics		*/
    char	value;		/* Pointer to data in current record		*/
};

The data type returned for the field is one of the following:


FIELD DATA TYPE API DATA TYPE
Blob M
Byte B
Character C
Currency Y
Date D
DateTime T
Float F
Integer I
Logical L
Numeric N
Memo M
Packed P *
Quad Q *
Real R
Short S
Zoned Z
Vaxdate V *


* OpenVMS only

The storage size of a field in the record can be different to the display width of the field.


EXAMPLE

The following example looks up to the width of the specified field in the current database.


#include <stdio.h>
#include "dbapi.h"
 
dbapi_field_lookup()
{
    struct API_FIELD	*fldvalue;
    struct API_FIELD	fldinfo;
    int			width;
 
    if (_parinfo(1) == API_CTYPE) {
       fldvalue = FIELD_LOOKUP(_parc(1), &fldinfo);
       if (fldvalue == NULL) width = -1;
       else width = fldvalue->width;
    } else width = -1;
 
    _retni( width );
}


SEE ALSO

BLOB_READ(), BLOB_RECLAIM(), BLOB_SIZE(), BLOB_UPDATE(), BLOB_WRITE(), DBF_FETCH(), DBF_GATHER(), DBF_RECBUFFER(), DBF_SCATTER(), DBF_SEEK(), FIELD_COUNT(), FIELD_NAME(), FIELD_UPDATE(), FIELD_VALUE(), MEMO_MLINE(), MEMO_MLCOUNT(), MEMO_READ(), MEMO_RECLAIM(), MEMO_SIZE(), MEMO_UPDATE(), MEMO_WRITE()