xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

DbFieldInfo()

Retrieves information about a database field

Syntax

DbFieldInfo( <nInfo>, <nFieldPos> ) --> xFieldInfo

Arguments

<nInfo>
The parameter is a numeric value specifying the type of information to query about a database field. #define constants listed in the table below must be used for <nInfo>.
<nFieldPos>
A numeric value specifying the ordinal position of the field to query. Valid values are in the range from 1 to FCount().

Return

DbFieldInfo() returns the queried information as supplied by the replaceable database driver (RDD).

Description

DbFieldInfo() allows for querying detailed field information from the replaceable database driver (RDD). Depending on database and RDD used, different information may be available. The type of information to retrieve is specified with #define constants available in the DBINFO.CH and DBSTRUCT.CH header files.

Constants for DbFieldInfo()
ConstantReturn value
 
DBSTRUCT.CH
 
DBS_DECNumber of decimal places for the field.
DBS_LENNumeric length of the field.
DBS_NAMECharacter string holding the name of the field.
DBS_TYPECharacter identifying the data type of the field.
 
DBINFO.CH
 
DBS_BLOB_LENNumber of bytes stored in a memo field (BLOB).
DBS_BLOB_OFFSETNumeric file offset into memo file of the data in a memo field.
DBS_BLOB_POINTERNumeric value for usage with e.g. BlobDirectGet(), BlobDirectImport().
DBS_BLOB_TYPECharacter indicating the data type of a memo field (BLOB).

By default, DbFieldInfo() operates in the current work area. Use an aliased expression to query field information in different work areas.

Info

See also:BlobDirectGet(), BlobDirectImport(), DbInfo(), DbOrderInfo(), DbRecordInfo(), DbStruct(), FieldDec(), FieldLen(), FieldName(), FieldType()
Category: Database functions , Field functions
Header:Dbinfo.ch, Dbstruct.ch
Source:rdd\dbcmd.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example retrieves structural information for a
// single database with a user defined function.

   #include "Dbstruct.ch"

   PROCEDURE Main

      USE Customer
      AEval( FieldStruct( 1 ), {|x| QOut( x ) } )
      USE

   RETURN

   FUNCTION FieldStruct( nFieldPos )
      LOCAL aFStruct[4]

      aFStruct[DBS_NAME] := DbFieldInfo( DBS_NAME, nFieldPos )
      aFStruct[DBS_TYPE] := DbFieldInfo( DBS_TYPE, nFieldPos )
      aFStruct[DBS_LEN ] := DbFieldInfo( DBS_LEN , nFieldPos )
      aFStruct[DBS_DEC ] := DbFieldInfo( DBS_DEC , nFieldPos )

   RETURN aFStruct

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe