Three subroutines are provided with D3 that can be used to directly reference D3 indexes from ODBC using either of the two methods described above. These subroutines are in the sql,bpnf, file.
To open a D3 index given the file and index correlative use:
subroutine sql_root(root, file, correlative)
The file parameter should be passed in with the full path name (for example, ba,entity,) and the correlative should match the correlative with which the index was created (for example, a1). The root parameter returns an integer index which can be used with subsequent index subroutines.
This subroutine is roughly equivalent to the FlashBASIC root statement.
The syntax has these parameters:
Parameter | In/Out | Description |
---|---|---|
root | out | This value contains an integer index used for future index subroutine calls. |
file | in | The full path name of the file where the index resides (for example, ba,entity,). |
correlative | in | The index correlative that was used to create the index. |
subroutine sql_key(operator, root, key_val, item_id, val_ctr)
Returns an index match based on the passed key value and item-ID.
This subroutine is equivalent to the FlashBASIC key statement.
The syntax has these parameters:
Parameter | In/Out | Description |
---|---|---|
operator | in | This is an operator indicating the type of match to perform. The N operator finds the next key match in the index while the P operator finds the previous key match in the index. |
root | in | The root index returned by sql_root. |
Key_val | in/out | On input, this is the key to match. On output, the routine returns the key value that it matched. |
Item_id | in/out | When doing an initial random search, this should be passed as a null string. The routine returns the first item_id which matches the requested key. If a sequential pass through the index is desired, the sql_key routine can be called repeatedly, passing it the previous key_val and item_id values from the previous call. |
Val_ctr | in/out | Always pass 0 for this parameter on an initial random search. The subroutine returns val_ctr as the MultiValue, nested row ID, where it found the index key if the data was nested. |
To close a D3 index use:
subroutine sql_close_index(root)
This subroutine has no equivalent in FlashBASIC, but is necessary when dealing with indexes from ODBC as there are a limited number of index descriptors available.
The syntax has this parameter:
Parameter | In/Out | Description |
---|---|---|
root | out | This value contains the integer index returned by the sql_root call. This index will be closed and cannot be used again without re-opening it. |