Click or drag to resize

DbOrderInfo Function

Return and optionally change information about orders and index files.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.10
Syntax
 FUNCTION DbOrderInfo(
	 kInfoType AS USUAL,
	 cIndexFile AS USUAL,
	 uOrder AS USUAL,
	 uNewSetting AS USUAL
) AS USUAL
View Source

Parameters

kInfoType
Type: Usual
Specifies the type of information.  The constants are listed below.  Note, however, that not all constants are supported for all RDDs.
Important!  DBOI_USER is a constant that returns the minimum value that third-party RDD developers can use for defining new <kInfoType> parameters.  Values less than DBOI_USER are reserved for Computer Associates development.
cIndexFile
Type: Usual
The name of an index file, including an optional drive and directory (no extension should be specified).  Use this argument with <cOrder> to remove ambiguity when there are two or more orders with the same name in different index files.
If <cIndexFile> is not open by the current process, a runtime error is raised.
uOrder
Type: Usual
The name of the order about which you want to obtain information or a number representing its position in the order list.  (For single-order index files, the order name is the eight-letter index file name.)  Using the order name is the preferred method since the position may be difficult to determine using multiple-order index files.  Invalid values are ignored.
If no index file or order is specified, the controlling order is assumed.
uNewSetting
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.
DBOI_BAGEXT Returns the default order bag file extension as a string. This is similar to DBOI_INDEXEXT except it applies only to those RDD's supporting multiple orders such as DBFCDX.
DBOI_BAGNAME Returns the name of the specified order bag file as a string. This is similar to DBOI_INDEXNAME except it applies only to those RDD's supporting multiple orders such as DBFCDX.
DBOI_CONDITION Returns the for condition of the specified order as a string.
DBOI_CUSTOM Returns and optionally sets the logical flag indicating whether the specified order is custom built (for RDDs that support custom built orders).  Note that although you can turn the custom built flag on for a standard order by specifying TRUE for the <uNewSetting> argument, you cannot turn a custom built order into a standard order.  Specifying FALSE for <uNewSetting> is the same as not specifying the argument at all — both return the current setting.
DBOI_EXPRESSION Returns the order key expression of the specified order as a string.

DBOI_FULLPATH Returns the full path of the specified index file as a string.
DBOI_HPLOCKING Returns a logical flag indicating whether the specified index file uses the high performance index locking schema (see IndexHPLock() function).
DBOI_INDEXEXT Returns the default index file extension as a string.
DBOI_INDEXNAME Returns the name of the specified index file as a string.
DBOI_ISCOND Returns a logical flag that determines whether the specified order was defined using a for condition.
DBOI_ISDESC Returns the logical flag that determines if the specified order is descending.  For drivers that support dynamically setting the descending flag at runtime, specify the new value as a logical, using DBOrderInfo(DBOI_ISDESC, [<cIndexFile>], [<cOrder> | <nPosition>], <lNewSetting>).  The current setting is returned before it is changed.
DBOI_KEYCOUNT Returns the number of keys in the specified order.
DBOI_KEYDEC Returns the number of decimals in the key of the specified order.
DBOI_KEYSINCLUDED
Returns the number of keys included in the specified order so far.  This is primarily useful for conditional orders.  It can be used during the status display process (with the EVAL clause of the INDEX command).
DBOI_KEYSIZE Returns the size of the key in the specified order as a number.
DBOI_KEYTYPE Returns the data type of the key in the specified order as a string.
DBOI_KEYVAL Returns the key value of the current record in the specified order.
DBOI_LOCKOFFSET Returns the locking offset (see NewIndexLock() function) for the specified index file as a numeric value.
DBOI_NAME Returns the name of the specified order as a string.
DBOI_NUMBER Returns the numeric position of the specified order in the order list.
DBOI_ORDERCOUNT
Returns the number of orders defined in the specified index file.
DBOI_POSITION Returns the logical record number of the current record within the specified order.
DBOI_RECNO Returns the physical record number of the current record within the specified order.
DBOI_SCOPEBOTTOM
Returns the bottom boundary of the scope for the specified order.
DBOI_SCOPETOP Returns the top boundary of the scope for the specified order.
DBOI_SETCODEBLOCK
Returns the key for the specified order as a code block.
DBOI_UNIQUE Returns a logical flag indicating whether the specified order has the unique attribute set.

Return Value

Type: Usual
If <uNewSetting> is not specified, DBOrderInfo() returns the current setting.  If <uNewSetting> is specified, the previous setting is returned.
Remarks
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 uses DBOI_NAME to save the current controlling order.  After changing to a new controlling order, it uses the saved value to restore the original order:
X#
USE customer INDEX name, serial NEW
cOrder := DBOrderInfo(DBOI_NAME)                // name
Customer->DBSetOrder("serial")
? DBOrderInfo(DBOI_NAME)                        // serial
Customer->DBSetOrder(cOrder)
? DBOrderInfo(DBOI_NAME)                        // name
This example uses aliased expressions to return the default index file extension (using DBOI_INDEXEXT) in two different work areas:
X#
USE sales INDEX all_sales VIA "DBFCDX" NEW
USE customer INDEX name, serial VIA "DBFNTX" NEW
? Sales->DBOrderInfo(DBOI_INDEXEXT)        // .CDX
? Customer->DBOrderInfo(DBOI_INDEXEXT)        // .NTX
In this example, DBOrderInfo(DBOI_INDEXEXT) checks for the existence of the CUSTOMER index file independent of the RDD linked into the current work area:
X#
USE customer NEW
IF !File("customer" + DBOrderInfo(DBOI_INDEXEXT))
        Customer->DBCreateIndex("customer", "CustName",;
                {|| Customer->CustName})
ENDIF
This example accesses the key expression of several orders from the same index file:
X#
USE customer INDEX all_cust VIA "DBFMDX" NEW
Customer->DBSetOrder("serial")
? DBOrderInfo(DBOI_EXPRESSION,, "name")
// Result: key expression for name order
? DBOrderInfo(DBOI_EXPRESSION,, "serial")
// Result: key expression for serial order
This example uses DBOrderInfo() as part of a TOTAL ON key expression.  Since DBOrderInfo() returns the expression as a string, it is specified using a macro expression to force evaluation of the key expression:
X#
USE sales INDEX salesman NEW
TOTAL ON &(DBOrderInfo(DBOI_EXPRESSION)) ;
        FIELDS SaleAmount TO summary
In this example, ALL_CUST.MDX contains three orders named CUACCT, CUNAME, CUZIP.  The DBOI_INDEXNAME constant is used to display the name of the index file using one of its orders:
X#
USE customer VIA "DBFNTX" NEW
Customer->DBSetIndex("all_cust")
? DBOrderInfo(DBOI_INDEXNAME,, "cuname")
// Returns: all_cust
The following example searches for CUNAME in the order list:
X#
USE customer VIA "DBFNTX" NEW
Customer->DBSetIndex("cuacct")
Customer->DBSetIndex("cuname")
Customer->DBSetIndex("cuzip")
? DBOrderInfo(DBOI_NUMBER,, "cuname")        // 2
This example retrieves the "for condition" from an order:
X#
USE customer NEW
INDEX ON Customer->Acct TO customer ;
        FOR Customer->Acct > "AZZZZZ"
? DBOrderInfo(DBOI_CONDITION,, "customer")
// Returns: Customer->Acct > "AZZZZZ"
See Also

Reference

DBServer:FieldInfo
DBServer:Info
DBServer:OrderInfo
DBServer:RecordInfo