DbServer.FieldInfo Method (Typed) | |
Return and optionally change information about a field.
Namespace:
XSharp.VO.SDK
Assembly:
XSharp.VORDDClasses (in XSharp.VORDDClasses.dll) Version: 2.19
Syntax VIRTUAL METHOD FieldInfo(
kFieldInfoType,
uField,
uFieldVal
) AS USUAL CLIPPER
[ClipperCallingConventionAttribute(new string[] { ... })]
public virtual Usual FieldInfo(
Usual kFieldInfoType = default,
Usual uField = default,
Usual uFieldVal = default
)
Request Example
View SourceParameters
- kFieldInfoType (Optional)
- Type: Usual
Specifies the type of information. The constants are described in the Remarks section below. Note, however, that not all constants are supported for all RDDs.
- uField (Optional)
- Type: Usual
The name, number, or symbol representing the position of the field in the database file structure or a numeric pointer to a BLOB.
Only certain kFieldInfoType constants designed to work with BLOB fields—all noted in the Constants section below—allow specifying the
field using a pointer; all others require specifying the field by its position.
- uFieldVal (Optional)
- Type: Usual
If specified, this parameter is used to change the value of a setting. The data type (and whether uNewSetting can be specified), depends on the kInfoType constant and is documented in the Constants section below.
Return Value
Type:
Usual
If
uNewSetting is not specified, DBServer:FieldInfo() returns the current setting. If
uNewSetting is specified, the previous setting is returned.
Remarks Tip |
---|
The values in the table below exist both as DEFINEs and also as members of the DbFieldInfo enum.
You can see the numeric values of the defines in the documentation of this Enum.
|
Constants | Description |
---|
DBS_NAME | Returns the name of the field. |
DBS_TYPE | Returns the data type of the field. |
DBS_LEN | Returns the length of the field. |
DBS_DEC | Returns the number of decimal places for the field. |
DBS_ALIAS |
Returns and optionally changes an alternate name (or alias) by which a field can be referenced (by default, same as DBS_NAME).
|
DBS_PROPERTIES | Returns the number of properties defined for a field. |
DBS_BLOB_DIRECT_LEN |
Returns the length of data in a BLOB as an unsigned long integer, without referencing a particular memo field.
For strings, the return value is the length of the string in bytes; for arrays, it is the number of elements in the first dimension;
for all other data types, it returns -1. With this constant, you must specify the BLOB using a numeric pointer obtained from DBServer:BLOBDirectPut(),
DBServer:BLOBDirectImport(), or DBServer:FieldInfo(DBS_BLOB_POINTER, ... />).
|
DBS_BLOB_DIRECT_TYPE |
To determine the data type of BLOB data, without reference to a particular memo field, use DBServer:FieldInfo(DBS_BLOB_DIRECT_TYPE, ...).
With this constant, you must specify the BLOB using a numeric pointer obtained from DBServer:BLOBDirectPut(), DBServer:BLOBDirectImport(),
or DBServer:FieldInfo(DBS_BLOB_POINTER, ...).
See DBS_BLOB_TYPE for a table of possible return values.
|
DBS_BLOB_LEN |
Returns the length of the BLOB data in a memo field as an unsigned long integer. For strings, the return value is the length of the string in bytes;
for arrays, it is the number of elements in the first dimension; for all other data types, it returns -1.
Tip |
---|
DBServer:FieldInfo(DBS_BLOB_LEN, ...) has a performance advantage over the Len() function. |
|
DBS_BLOB_POINTER | Returns a numeric pointer to the BLOB data associated with a memo field. |
DBS_BLOB_TYPE |
Unlike memo fields maintained in .DBT files, BLOB files allow you to store many different types of data in memo fields.
However, the standard functions for determining data types, such as ValType(), simply treat BLOB fields as regular memo fields.
To determine the actual type of BLOB data stored in a memo field, use DBServer:FieldInfo(DBS_BLOB_TYPE, ...).
The data type of the return value is string and can be interpreted using this table:
Returns | Meaning |
---|
? | Blank (empty/uninitialized field) | A | Array | C | String | D | Date | E | Error | L | Logical | N | Numeric | U | Undefined (NIL was stored) |
|
DBS_USER | Start of user defined DBS_ values. |
Tip |
---|
DBS_USER is a constant that returns the minimum value that third-party RDD developers can
use for defining new properties. Values less than DBS_USER are reserved for X# development.
|
DBServer:FieldInfo() retrieves information about the state of a field (column).
The field information that is available is defined by the RDD. In the DBF model, this is limited to the information stored in the DBF file structure (that is, name, length, number of decimals, and data type) plus the field alias that can be changed at runtime.
To support RDDs for other database models (such as dictionary based databases) that store more information about each field or column, the X# RDD API has been enhanced. The DBServer:FieldInfo() method is designed to allow for additional
kInfoType values that can be defined by third-party RDD developers.
Examples
The following examples use DBServer:FieldInfo() to retrieve field information:
1METHOD DBOutStruct() CLASS Customer
2LOCAL aStruct AS ARRAY
3LOCAL wFcount AS DWORD
4LOCAL i AS DWORD
5aStruct := {}
6wFcount := FCount()
7FOR i := 1 UPTO wFcount
8AAdd(aStruct,;
9{SELF:FieldInfo(DBS_NAME, i),;
10SELF:FieldInfo(DBS_TYPE, i),;
11SELF:FieldInfo(DBS_LEN, i),;
12SELF:FieldInfo(DBS_DEC, i)})
13NEXT
14RETURN aStruct
The next example illustrates using the third parameter to assign an alias to a field name:
1METHOD Start() CLASS App
2LOCAL oDBDate AS DBServer
3oDBDate := DateBook{}
4oDBDate:FieldInfo(DBS_ALIAS,;
5oDBDate:FieldPos("Name"),;
6"NewName")
7? Name
8? NewName
9...
See Also