ChangeISAMContext
Change current ISAM context.
Short Name
CHGICON()
Type
ISAM function
Declaration
COUNT ChangeISAMContext(COUNT contextid)
Description
ChangeISAMContext() accepts the context ID returned as the result of a successful call to OpenISAMContext(). If ChangeISAMContext() is successful, the current ISAM position for the data file associated with the context ID is:
If the context ID passed to ChangeISAMContext() is the current context for the associated data file, ChangeISAMContext() has no effect.
Return
Value |
Symbolic Constant |
Explanation |
|---|---|---|
0 |
NO_ERROR |
Successful change. |
590 |
NCON_ERR |
Non-existent context ID. |
See FairCom DB Error Codes for a complete listing of valid FairCom DB error values.
Example
See the example for OpenISAMContext(). The following example uses ctSetAutoContextId() to increase performance.
FILNO datno1,datno2; /* data file numbers */
pVOID bufptr1,bufptr2; /* data buffer pointer */
COUNT contextID_1,contextID_2,contextID_3; /* context ID's */
OpenFileWithResource(datno1,"data1",ctSHARED);
OpenFileWithResource(datno2,"data2",ctSHARED);
/* move to first record for datno1 using first key */
FirstRecord(datno1 + 1,bufptr1);
/* establish first context for datno1 at first record. keyno == -1 saves all key positions. */
contextID_1 = OpenISAMContext(datno1,-1,-1);
/* move to first record for datno2 using third key. */
FirstRecord(datno2 + 3,bufptr2);
/* establish first context for datno2 at first record. keyno != -1 saves only key value for third key. */
contextID_2 = OpenISAMContext(datno2, datno2 + 3,-1);
NextRecord(datno1 + 1,bufptr1);
/* position datno1 at third record by first key. */
NextRecord(datno1 + 1,bufptr1);
/* Third record by first key becomes the saved position for contextID_1 and contextID_3 becomes the active context for datno1. */
contextID_3 = OpenISAMContext(datno1,-1,-1);
/* move from third record by first key, to the next record using the second key. Call this record 4' */
NextRecord(datno1 + 2,bufptr1);
/* Save record 4' as contextID_3. Make the 3rd record the current position for datno1, and contextID_1 becomes the active context for datno1. contextID_2 is still the active context for datno2. */
ctSetAutoContextId(contextID_1);
/* move to the 4th record by key 1 for datno1.*/
NextRecord(datno1 + 1,bufptr1);
See also
CloseISAMContext, OpenISAMContext