home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / bde / snipit.pak / TBLINFO.C < prev    next >
Encoding:
C/C++ Source or Header  |  1997-07-24  |  4.3 KB  |  126 lines

  1. // BDE - (C) Copyright 1995 by Borland International
  2.  
  3. // TblInfo.c
  4. #include "snipit.h"
  5.  
  6. static const char szTblName1[] = "orders";
  7. static const char szTblType1[] = szPARADOX;
  8.  
  9. //=====================================================================
  10. //  Function:
  11. //          TblInfo();
  12. //
  13. //  Description:
  14. //          This example displays information about a table, including:
  15. //          fields, indexes, validity checks, referential integrity,
  16. //          and security descriptors.
  17. //=====================================================================
  18. void
  19. TblInfo (void)
  20. {
  21.     DBIResult   rslt;       // Return value from IDAPI functions
  22.     hDBIDb      hDb;        // Handle to the database
  23.     hDBICur     hListCur;   // Cursor handle used for the lists of
  24.                             //   information
  25.  
  26.     Screen("*** Getting Table Information ***\r\n");
  27.  
  28.     BREAK_IN_DEBUGGER();
  29.  
  30.     Screen("    Initializing IDAPI... ");
  31.     if (InitAndConnect(&hDb) != DBIERR_NONE)
  32.     {                                        
  33.         Screen("*** End of Example ***");
  34.         return;
  35.     }
  36.  
  37.     Screen("    Setting the database directory...");
  38.     rslt = DbiSetDirectory(hDb, (pCHAR) szTblDirectory);
  39.     ChkRslt(rslt, "SetDirectory");
  40.  
  41.     Screen("    Get the fields for the %s table...", szTblName1);
  42.     rslt = DbiOpenFieldList(hDb, (pCHAR) szTblName1, (pCHAR) szTblType1,
  43.                             FALSE, &hListCur);
  44.     ChkRslt(rslt, "OpenFieldList");
  45.  
  46.  
  47.     Screen("    Display the fields of the %s table as IDAPI types...",
  48.            szTblName1);
  49.     DisplayInMemoryTable(hListCur, 0);
  50.  
  51.     Screen("\r\n    Close the schema table...");
  52.     rslt = DbiCloseCursor(&hListCur);
  53.     ChkRslt(rslt, "CloseCursor");
  54.  
  55.     Screen("    Get the list of indexes on the %s table...", szTblName1);
  56.     rslt = DbiOpenIndexList(hDb, (pCHAR) szTblName1, (pCHAR) szTblType1,
  57.                             &hListCur);
  58.     ChkRslt(rslt, "OpenIndexList");
  59.  
  60.     Screen("    Display the indexes on the %s table...", szTblName1);
  61.     DisplayInMemoryTable(hListCur, 0);
  62.  
  63.     Screen("\r\n    Close the schema table...");
  64.     rslt = DbiCloseCursor(&hListCur);
  65.     ChkRslt(rslt, "CloseCursor");
  66.  
  67.     Screen("    Get the validity checks for the %s table...",
  68.            szTblName1);
  69.     rslt = DbiOpenVchkList(hDb, (pCHAR) szTblName1, (pCHAR) szTblType1,
  70.                            &hListCur);
  71.     ChkRslt(rslt, "OpenVchkList");
  72.  
  73.     Screen("    Display the validity checks of the %s table...",
  74.            szTblName1);
  75.     DisplayInMemoryTable(hListCur, 0);
  76.  
  77.     Screen("\r\n    Close the schema table...");
  78.     rslt = DbiCloseCursor(&hListCur);
  79.     ChkRslt(rslt, "CloseCursor");
  80.  
  81.     Screen("    Get the referential integrity links for the %s table...",
  82.            szTblName1);
  83.     rslt = DbiOpenRintList(hDb, (pCHAR) szTblName1, (pCHAR) szTblType1,
  84.                            &hListCur);
  85.     ChkRslt(rslt, "OpenRintList");
  86.  
  87.     Screen("    Display the referential integrity links for the %s"
  88.            " table...", szTblName1);
  89.     DisplayInMemoryTable(hListCur, 0);
  90.  
  91.     Screen("\r\n    Close the schema table...");
  92.     rslt = DbiCloseCursor(&hListCur);
  93.     ChkRslt(rslt, "CloseCursor");
  94.  
  95.     Screen("    Get the security descriptors for the %s table...",
  96.            szTblName1);
  97.     rslt = DbiOpenSecurityList(hDb, (pCHAR) szTblName1, (pCHAR) szTblType1,
  98.                                &hListCur);
  99.     ChkRslt(rslt, "OpenSecurityList");
  100.  
  101.     Screen("    Display the security descriptors for the %s"
  102.            " table...", szTblName1);
  103.     DisplayInMemoryTable(hListCur, 0);
  104.  
  105.     Screen("\r\n    Close the schema table...");
  106.     rslt = DbiCloseCursor(&hListCur);
  107.     ChkRslt(rslt, "CloseCursor");
  108.  
  109.     Screen("    Get the family list for the %s table...", szTblName1);
  110.     rslt = DbiOpenFamilyList(hDb, (pCHAR) szTblName1, (pCHAR) szTblType1,
  111.                              &hListCur);
  112.     ChkRslt(rslt, "OpenFamilyList");
  113.  
  114.     Screen("    Display the family list for the %s table...", szTblName1);
  115.     DisplayInMemoryTable(hListCur, 0);
  116.  
  117.     Screen("\r\n    Close the schema table...");
  118.     rslt = DbiCloseCursor(&hListCur);
  119.     ChkRslt(rslt, "CloseCursor");
  120.  
  121.     Screen("    Close the database and exit IDAPI...");
  122.     CloseDbAndExit(&hDb);
  123.  
  124.     Screen("\r\n*** End of Example ***");
  125. }
  126.