DbStruct Function | |
Create an array containing the structure of a database file.
Namespace:
XSharp.RT
Assembly:
XSharp.RT (in XSharp.RT.dll) Version: 2.21
Syntax FUNCTION DbStruct() AS ARRAY
public static Array DbStruct()
Request Example
View SourceReturn Value
Type:
Array
The structure of the database file in an array whose length is equal to the number
of fields in the database file.
Each element of the array is a subarray containing information for one field.
The subarrays have the following format:
Constant | 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 | cAlias |
If there is no database file in use in the work area, DBStruct() will generate
a runtime error.
Remarks
DBStruct() operates like COPY STRUCTURE EXTENDED by creating an array of structure
information rather than a database file of structure information.
There is another function, DBCreate(), that can create a database file from
the structure array.
By default, this function operates on the currently selected work area.
It can be made to operate on an unselected work area by specifying
it within an aliased expression
Examples
This example opens two database files, then creates an array containing the
database structure using DBStruct() within an aliased expression.
The field attributes are then listed using AEval():
1LOCAL aStruct
2USE customer NEW
3USE invoices NEW
4aStruct := Customer->DBStruct()
5AEval(aStruct, {|aField|QOut(aField[DBS_NAME]),;
6QOut(aField[DBS_TYPE]), QOut(aField[DBS_LEN]),;
7QOut(aField[DBS_DEC]), QOut(aField[DBS_ALIAS])})
See Also