home *** CD-ROM | disk | FTP | other *** search
- // BDE - (C) Copyright 1995 by Borland International
-
- // navigate.c
- #include "snipit.h"
-
- static const char szTblName[] = "customer";
- static const char szTblType[] = szPARADOX;
-
- //========================================================================
- // Function:
- // Navigate();
- //
- // Description:
- // This sample code will open the Customer table and
- // navigate through it, doing operations such as getting and
- // displaying the current record, getting the next record,
- // getting the previous record, and getting the record relative
- // to the offset given.
- //========================================================================
- void
- Navigate (void)
- {
- DBIResult rslt; // Return value from IDAPI functions
- hDBIDb hDb; // Handle to the database
- hDBICur hCur; // Handle to the table
-
- Screen("*** Cursor Navigation Example ***\r\n");
-
- BREAK_IN_DEBUGGER();
-
- Screen(" Initializing IDAPI...");
- if (InitAndConnect(&hDb) != DBIERR_NONE)
- {
- Screen("\r\n*** End of Example ***");
- return;
- }
-
- Screen(" Setting the database directory...");
- rslt = DbiSetDirectory(hDb, (pCHAR) szTblDirectory);
- ChkRslt(rslt, "SetDirectorry");
-
- Screen(" Opening the %s table...", szTblName);
- rslt = DbiOpenTable(hDb, (pCHAR) szTblName, (pCHAR) szTblType,
- NULL, NULL, NULL, dbiREADWRITE, dbiOPENSHARED,
- xltFIELD, FALSE, NULL, &hCur);
- if (ChkRslt(rslt, "OpenTable") != DBIERR_NONE)
- {
- CloseDbAndExit(&hDb);
- Screen("\r\n*** End of Example ***");
- return;
- }
-
- Screen(" Display the first ten records in the table...");
- DisplayInMemoryTable(hCur, 10);
-
- Screen("\r\n Set the current record to the first record in the"
- " table...");
- rslt = DbiSetToBegin(hCur);
- ChkRslt(rslt, "SetToBegin");
-
- // We need to display the next record as we are currently at the
- // BOF crack.
- DisplayNextRecord(hCur);
-
- Screen("\r\n Change to the next record...");
- rslt = DbiGetNextRecord(hCur, dbiNOLOCK, NULL, 0);
- ChkRslt(rslt, "GetNextRecord");
-
- Screen(" New current record:");
- DisplayCurrentRecord(hCur);
-
- // Skip 3 records. We will be passing the function a NULL
- // record buffer as we only want to skip and we don't want to fill
- // a record buffer.
- Screen("\r\n Getting the third record relative to the current"
- " record...\r\n New current record:");
-
- rslt = DbiGetRelativeRecord(hCur, 3, dbiNOLOCK, NULL, 0);
- ChkRslt(rslt, "GetRelativeRecord");
- DisplayCurrentRecord(hCur);
-
-
- Screen("\r\n Set the cursor to the previous record...");
- Screen(" New current record:");
-
- rslt = DbiGetPriorRecord(hCur, dbiNOLOCK, NULL, 0);
- ChkRslt(rslt, "GetPriorRecord");
- DisplayCurrentRecord(hCur);
-
- Screen("\r\n Set the current record to the last record in the"
- " table...");
- Screen(" New current record:");
-
- // Set the cursors current record pointer to EOF.
- rslt = DbiSetToEnd(hCur);
- ChkRslt(rslt, "SetToEnd");
-
- // Set the cursors to the last record in the table.
- rslt = DbiGetRelativeRecord(hCur, -1, dbiNOLOCK, NULL, 0);
- ChkRslt(rslt, "GetRelativeRecord");
-
- DisplayCurrentRecord(hCur);
-
- Screen("\r\n Close the database and exit IDAPI...");
- CloseDbAndExit(&hDb);
-
- Screen("\r\n*** End of Example ***");
- }
-
-
-