home *** CD-ROM | disk | FTP | other *** search
/ Borland Programmer's Resource / Borland_Programmers_Resource_CD_1995.iso / code / kdbf / px2bde.txt < prev    next >
Encoding:
Text File  |  1995-05-19  |  27.6 KB  |  669 lines

  1.                                Types
  2.  
  3. Paradox Engine       BDE            Variable name in this doc
  4. -----------------------------------------------------------------
  5. PXCODE               DBIResult      rslt
  6. TABLEHANDLE          hDBICur        tabH
  7. RECORDHANDLE         pBYTE          recH
  8. FIELDNUMBER          UINT16         iFld
  9. LOCKHANDLE           UINT32
  10. RECORDNUMBER         UINT32         recNum
  11. BLOBHANDLE           INT16
  12.  
  13.  
  14.                               Functions
  15.  
  16. Paradox Engine       BDE
  17. -----------------------------------------------------------------
  18. BLANK                DbiPutField(tabH, iFld, recH, NULL);
  19.                      (Cannot compare Field Data with BLANK in
  20.                      IDAPI. Use the value returned from
  21.                      DbiGetField in bIsBlank to determine if a
  22.                      field is blank.)
  23.  
  24. ISBANK()             Use the blank parameter in
  25.                      DbiGetField(tabH, iFld, recH, pDest,
  26.                                  &bIsBlank);
  27.                      or
  28.                      DbiVerifyField(tabH, iFld, pSrc, &bIsBlank);
  29.  
  30. PXBlobClone()        Not Supported.
  31.                      (Private BLOBs are not supported in IDAPI)
  32.  
  33. PXBlobClose()
  34. accept == FALSE      DbiFreeBlob(tabH, recH, iFld);
  35. accept == TRUE       Not required in IDAPI. Note that
  36.                      DbiFreeBlob(tabH, recH, iFld) needs to be
  37.                      called _after_ adding a record containing a
  38.                      BLOB to a table.
  39.  
  40. PXBlobDrop()         DbiGetRecord(tabH, dbiNOLOCK, recH, NULL);
  41.                      DbiTruncateBlob(tabH, recH, iFld, 0);
  42.                      DbiModifyRecord(tabH, recH, FALSE);
  43.  
  44.  
  45. PXBlobGet()          DbiGetBlob(tabH, recH, iFld, iOff, iLen,
  46.                                 pDest, &iRead);
  47.  
  48. PXBlobGetSize()      DbiGetBlobSize(tabH, recH, iFld, piSize);
  49.  
  50. PXBlobOpenRead()     DbiOpenBlob(tabH, recH, iField,dbiREADONLY);
  51.  
  52. PXBlobOpenWrite()    DbiOpenBlob(tabH, recH, iField,
  53.                                  dbiREADWRITE);
  54.  
  55. PXBlobPut()          DbiPutBlob(tabH, recH, iFld, iOff, iLen,
  56.                                 pSrc);
  57.  
  58. PXBlobQuickGet()     DbiGetBlobHeading(tabH, iFld, recH, &iSize);
  59.                      (Paradox Tables only.)
  60.  
  61. PXDateDecode()       DbiDateDecode(dateD, piMon, piDay, piYear);
  62.  
  63. PXDateEncode()       DbiDateEncode(iMon, iDay, iYear, pdateD);
  64.  
  65. PXErrMsg()           DbiGetErrorString(iErrorCode, szError);
  66.                      or
  67.                      DbiGetErrorInfo(&ErrInfo);
  68.                      (Must be called imediately after the
  69.                       offending function - privides more
  70.                       information than DbiGetErrorString.)
  71.  
  72. PXExit()             DbiCloseDatabase(&hDb);
  73.                      DbiExit();
  74.  
  75. PXFldBlank()         DbiGetField(tabH, iFld, recH, NULL,
  76.                                  &bIsBlank);
  77.                      or
  78.                      DbiVerifyField(tabH, iFld, pSrc, &bIsBlank);
  79.                      bIsBlank = TRUE is field is blank.
  80.  
  81. PXFldHandle()        DbiGetFieldDescs(tabH, &fldDesc);
  82.                      fldDesc.iFldNum;
  83.  
  84. PXFldName()          DbiGetFieldDescs(tabH, &fldDesc);
  85.                      fldDesc.szName;
  86.  
  87. PXFldType()          DbiGetFieldDescs(tabH, &fldDesc);
  88.                      fldDesc.iFldType;
  89.                      fldDesc.iSubType;
  90.  
  91. PXGetAlpha()         DbiGetField(tabH, iFld, recH,
  92.                                  (pBYTE)szString, &bIsBlank);
  93.  
  94. PXGetDate()          DbiGetField(tabH, iFld, recH,
  95.                                  (pBYTE)&Date, &bIsBlank);
  96.  
  97. PXGetDefaults()      DbiOpenCfgInfoList(hCfg, eOpenMode,
  98.                                         eConfigMode, pszCfgPath,
  99.                                         &tabH);
  100.  
  101. PXGetDoub()          DbiGetField(tabH, iFld, recH,
  102.                                  (pBYTE)&Double, &bIsBlank);
  103.  
  104. PXGetLong()          DbiGetField(tabH, iFld, recH,
  105.                                  (pBYTE)&Long, &bIsBlank);
  106.  
  107. PXGetShort()         DbiGetField(tabH, iFld, recH,
  108.                                  (pBYTE)&Short, &bIsBlank);
  109.  
  110. PXInit()             Not Supported. See PXWinInit.
  111.  
  112. PXKeyAdd()           DbiAddIndex(hDb, tabH, szTblName, szTblType,
  113.                                  &IdxDesc);
  114.  
  115. PXKeyDrop()          DbiDeleteIndex(hDb, tabH, szTblName,
  116.                                     szTblType, NULL, NULL,
  117.                                     iIndexId);
  118.  
  119. PXKeyMap()           Not Supported.
  120.                      (Key Mapping is no longer needed - all
  121.                       pertinent information is put in the index
  122.                       descriptor - IdxDesc)
  123.  
  124. PXKeyNFlds()         DbiGetIndexSeqNo(tabH, NULL, NULL, 0,
  125.                                       &seqNo);
  126.                      DbiGetIndexDesc(tabH, seqNo, &idxDesc);
  127.                      idxDesc.iFldsInKey;
  128.                      (Note that Paradox in the only database
  129.                       which has the concept of a primary index)
  130.  
  131. PXKeyQuery()         Not Supported.
  132.                      (The BDE does not have any function like
  133.                       this. You need to call DbiGetIndexDescs()
  134.                       and then look for the index you want.  Once
  135.                       found all the information about that index
  136.                       is available to you in the structure.)
  137.  
  138. PXNetErrUser()       DbiErrGetErrorContext(ecUSERNAME,
  139.                                            szUserName);
  140.  
  141. PXNetFileLock()      DbiAcqPersistTableLock(hDb, (pCHAR)fileName,
  142.                                             Driver);
  143.  
  144. PXNetFileUnlock()    DbiRelPersistTableLock(hDb, (pCHAR)fileName,
  145.                                             Driver);
  146.  
  147. PXNetInit()          Not Support. See PXWinInit.
  148.  
  149. PXNetRecGotoLock()   Not Supported.
  150.                      (Can be simulated by setting a bookmark on
  151.                       the record which is locked and then
  152.                       switching to that bookmark:
  153.                       DbiSetToBookMark(tabH, pBookMark);)
  154.  
  155. PXNetRecLock()       DbiGetRecord(tabH, dbiWRITELOCK, NULL,
  156.                                   NULL);
  157.  
  158. PXNetRecLocked()     DbiIsRecordLocked(tabH, edbiLock, piLocks);
  159.  
  160. PXNetRecUnlock()     DbiRelRecordLock(tabH, FALSE);
  161.                      or durring the update of the record -
  162.                      DbiModifyRecord(tabH, recH, TRUE);
  163.  
  164. PXNetTblChanged()    Need to register a cbTABLECHANGED callback.
  165.                      (Paradox only.)
  166.  
  167. PXNetTblLock()       DbiAcqTableLock(tabH, eLockType);
  168.                      (Note that only Read and Write locks
  169.                       are supported by this function. For a
  170.                       FL on a table, open the table with
  171.                       the dbiOPENEXCL parameter or use the
  172.                       DbiAcqPersistTableLock function.)
  173.  
  174. PXNetTblRefresh()    DbiForceReread(tabH);
  175.  
  176. PXNetTableUnlock()   DbiRelTableLock(tabH, eLockType);
  177.  
  178. PXNetUserName()      DbiGetNetUserName(pzName);
  179.  
  180. PXPswAdd()           DbiAddPassword(szPassword);
  181.                      (Paradox tables only.)
  182.  
  183. PXPswDel()           DbiDropPassword(szPassword);
  184.                      (Paradox tables only.)
  185.                      
  186. PXPutAlpha()         DbiPutField(tabH, iFld, recH,
  187.                                  (pBYTE)szString);
  188.  
  189. PXPutBlank()         DbiPutField(tabH, iFld, recH, NULL);
  190.  
  191. PXPutDate()          DbiPutField(tabH, iFld, recH,
  192.                                  (pBYTE)&Date);
  193.  
  194. PXPutDoub()          DbiPutField(tabH, iFld, recH,
  195.                                  (pBYTE)&Double);
  196.  
  197. PXPutLong()          DbiPutField(tabH, iFld, recH,
  198.                                  (BYTE)&Long);
  199.  
  200. PXPutShort()         DbiPutField(tabH, iFld, recH,
  201.                                  (pBYTE)&Short);
  202.  
  203. PXRawGet()           DbiSetProp((hDBIObj)tabH, curXLTMODE,
  204.                                 xltNONE)
  205.                      DbiGetRecord(tabH, NULL, recH, NULL);
  206.  
  207. PXRawPut()           DbiSetProp((hDBIObj)tabH, curXLTMODE,
  208.                                 xltNONE)
  209.                      DbiInsertRecord(tabH, dbiNOLOCK, recH,
  210.                                      pDest);
  211.  
  212. PXRecAppend()        DbiAppendRecord(tabH, recH);
  213.  
  214. PXRecBufClose()      The application needs to release the memory
  215.                      associated with the record buffer. In 'C',
  216.                      call: free(recH).
  217.                      (Record buffers in IDAPI are owned by the
  218.                       application.)
  219.  
  220. PXRecBufCopy()       The application needs to copy the memory
  221.                      which is used for the record buffer. In 'C',
  222.                      call:
  223.                      memcpy(recHDest, recHSource, size).
  224.                      (Record buffers in IDAPI are owned by the
  225.                       application.)
  226.  
  227. PXRecBufEmpty()      DbiInitRecord(tabH, recH);
  228.  
  229. PXRecBufOpen()       The application needs to allocate memory for
  230.                      record buffer. In 'C', call:
  231.                      DbiGetCursorProps(tabH, &CurProps);
  232.                      recH = (pBYTE)malloc(CurProps.iRecBufSize
  233.                                           * sizeof(BYTE));
  234.                      (Record buffers in IDAPI are owned by the
  235.                       application.)
  236.  
  237. PXRecDelete()        DbiDeleteRecord(tabH, NULL);
  238.  
  239. PXRecFirst()         DbiSetToBegin(tabH);
  240.                      DbiGetNextRecord(tabH, dbiNOLOCK, NULL,
  241.                                       NULL);
  242.                      (IDAPI has the concept of Beginning of file,
  243.                       which is before the first record).
  244.  
  245. PXRecGet()           DbiGetRecord(tabH, dbiNOLOCK, recH, NULL);
  246.  
  247. PXRecGoto()          Not supported by the SQL Drivers.
  248.                      Example for use with 'C':
  249.                      DBIResult gotoRec(hDBICur tabH,
  250.                                        UINT32 recNum)
  251.                      {
  252.                          DBIResult   lastError;
  253.                          CURProps    curProps;
  254.  
  255.                          lastError = DbiGetCursorProps(tabH,
  256.                                                       &curProps);
  257.                          if (lastError != DBIERR_NONE)
  258.                          {
  259.                              return lastError;
  260.                          }
  261.  
  262.                          if (!strcmp(curProps.szTableType,
  263.                                      szPARADOX))
  264.                          {
  265.                              lastError = DbiSetToSeqNo(tabH,
  266.                                                        recNum);
  267.                          }
  268.                          else if (!strcmp(curProps.szTableType,
  269.                                           szDBASE))
  270.                          {
  271.                              lastError = DbiSetToRecordNo(tabH,
  272.                                                          recNum);
  273.                          }
  274.                          else
  275.                          {
  276.                              lastError = DBIERR_NOTSUPPORTED;
  277.                          }
  278.  
  279.                          return lastError;
  280.                      }
  281.  
  282. PXRecInsert()        DbiInsertRecord(tabH, dbiNOLOCK, recH);
  283.  
  284. PXRecLast()          DbiSetToEnd(tabH);
  285.                      DbiGetPriorRecord(tabH, dbiNOLOCK, NULL,
  286.                                        NULL);
  287.                      (IDAPI has the concept of End of File, which
  288.                       is after the last record).
  289.  
  290. PXRecNext()          DbiGetNextRecord(tabH, dbiNOLOCK, NULL,
  291.                                       NULL);
  292.  
  293. PXRecNFlds()         DbiGetCursorProps(tabH, &CurProps);
  294.                      lFlds = CurProps.iFields;
  295.  
  296. PXRecNum()           Not supported for SQL Tables.
  297.                      Example for use with 'C':
  298.                      DBIResult getCurRecNum(hDBICur tabH,
  299.                                             UINT32 *recNum)
  300.                      {
  301.                          DBIResult   lastError;
  302.                          CURProps    curProps;
  303.                          RECProps    recProps;
  304.                          
  305.                          lastError = DbiGetCursorProps(tabH,
  306.                                                       &curProps);
  307.                          if (lastError != DBIERR_NONE)
  308.                          {
  309.                              return lastError;
  310.                          }
  311.  
  312.                          if (!strcmp(curProps.szTableType,
  313.                                      szPARADOX))
  314.                          {
  315.                              lastError = DbiGetSeqNo(tabH,
  316.                                                 (pUINT32)recNum);
  317.                          }
  318.                          else if (!strcmp(curProps.szTableType,
  319.                                           szDBASE))
  320.                          {
  321.                              lastError = DbiGetRecord(tabH,
  322.                                                       dbiNOLOCK,
  323.                                                       NULL,
  324.                                                       &recProps);
  325.                              *recNum = recProps.iPhyRecNum;
  326.                          }
  327.                          else
  328.                          {
  329.                              lastError = DBIERR_NOTSUPPORTED;
  330.                          }
  331.  
  332.                          return lastError;
  333.                      }
  334.  
  335. PXRecPrev()          DbiGetPriorRecord(tabH, dbiNOLOCK, NULL,
  336.                                        NULL);
  337.  
  338. PXRecUpdate()        DbiModifyRecord(tabH, recH, TRUE);
  339.  
  340. PXSave()             DbiForceReread(tabH);
  341.  
  342. PXSetDefaults()      DbiOpenCfgInfoList() 
  343.  
  344. PXSetHWHandler()     Not Supported
  345.  
  346. PXSrchFld()          DbiSetToKey(tabH, keySEARCHEQ, FALSE, iFlds
  347.                                  iLen, pIdxBuf);
  348.  
  349. PXSrchKey()          DbiSwitchToIndex(&tabH, NULL, NULL, 0,
  350.                                       TRUE);
  351.                      DbiSetToKey(tabH, keySEARCHEQ, FALSE, iFlds
  352.                                  iLen, pIdxBuf);
  353.                      (can only search on the currently active
  354.                       index)
  355.  
  356. PXTblAdd()           DbiBatchMove(NULL, hSrcCur, NULL, hDestCur,
  357.                                   batAPPEND, 0, NULL, NULL, NULL,
  358.                                   NULL, NULL, NULL, NULL, NULL,
  359.                                   NULL, NULL, NULL, TRUE, FALSE,
  360.                                   NULL, TRUE);
  361.  
  362. PXTblClose()         DbiCloseCursor(&tabH);
  363.  
  364. PXTblCopy()          DbiCopyTable(hDb, TRUE, szSrcName,
  365.                                   szPARADOX, szDestName);
  366.  
  367. PXTblCreate()        DbiCreateTable(hDb, TRUE, &TblDesc);
  368.  
  369. PXTblCreateMode()    DbiCreateTable(hDb, TRUE, &TblDesc);
  370.                      (Use the optional parameters to change the
  371.                       level of the table.)
  372.  
  373. PXTblDecrypt()       Only Supported for Paradox Tables
  374.                      Example for use with 'C':
  375.                      DBIResult decryptTable(hDBIDb hDb,
  376.                                            const char *tableName)
  377.                      {
  378.                          CRTblDesc   crTblDesc;
  379.                          DBIResult   lastError;
  380.  
  381.                          // Clear the buffer
  382.                          memset(&crTblDesc, 0,
  383.                                 sizeof(CRTblDesc));
  384.  
  385.                          // name of the table
  386.                          strcpy(crTblDesc.szTblName, tableName);
  387.  
  388.                          lastError = DbiDoRestructure(hDb, 1,
  389.                                                       &crTblDesc,
  390.                                                       NULL, NULL,
  391.                                                       NULL,
  392.                                                       FALSE);
  393.  
  394.                          return lastError;
  395.                      }
  396.  
  397. PXTblDelete()        DbiDeleteTable(hDb, szTblName, szPARADOX);
  398.  
  399. PXTblEmpty()         DbiEmptyTable(hDb, tabH, szTblName,
  400.                                    szPARADOX);
  401.  
  402. PXTblEncrypt()       (Only Supported for Paradox Tables)
  403.                      Example for use with 'C':
  404.                      DBIResult encryptTable(hDBIDb hDb,
  405.                                            const char *tableName,
  406.                                            const char *password)
  407.                      {
  408.                          CRTblDesc   crTblDesc;
  409.                          DBIResult   lastError;
  410.  
  411.                          // Clear the buffer
  412.                          memset(&crTblDesc, 0,
  413.                                 sizeof(CRTblDesc));
  414.  
  415.                          // name of the table
  416.                          strcpy(crTblDesc.szTblName, tableName);
  417.                          // Master password suplied for the table
  418.                          crTblDesc.bProtected = TRUE;
  419.                          // Password for the table
  420.                          strcpy(crTblDesc.szPassword, password);
  421.  
  422.                          lastError = DbiDoRestructure(hDb, 1,
  423.                                                     &crTblDesc,
  424.                                                     NULL, NULL,
  425.                                                     NULL, FALSE);
  426.  
  427.                          return lastError;
  428.                      }
  429.  
  430. PXTblExist()         Not directly supported. Need to use
  431.                      DbiOpenTableList to get a list of available
  432.                      tables, and then search that list for the
  433.                      table. Example for use with 'C':
  434.                      BOOL tableExists(hDBIDb hDb,
  435.                                       const char *userName,
  436.                                       const char *tableName,
  437.                                       const char *tableType)
  438.                      {
  439.                          BOOL        exists = FALSE;
  440.                          BOOL        isLocal = TRUE;
  441.                          hDBICur     tabH   = 0;
  442.                          char        *tblName;
  443.                          TBLBaseDesc tblDesc;
  444.                          CHAR        remoteName[DBIMAXNAMELEN+1];
  445.                          DBIResult   lastError;
  446.  
  447.                          if ((!strcmp(tableType, szPARADOX)) ||
  448.                              (!strcmp(tableType, szDBASE)) ||
  449.                              (!strcmp(tableType, szASCII)))
  450.                          {
  451.                              tblName = _fstrtok((pCHAR)tableName,
  452.                                                 ".");
  453.                              isLocal = TRUE;
  454.                          }
  455.                          else if ((!strcmp(tableType, "ORACLE"))
  456.                                    ||
  457.                                   (!strcmp(tableType, "SYBASE")))
  458.                          {
  459.                              strcpy(remoteName, userName);
  460.                              strcat(remoteName, ".");
  461.                              strcat(remoteName, tableName);
  462.                              tblName = (pCHAR)tableName;
  463.                              isLocal = FALSE;
  464.                          }
  465.                          else
  466.                          {
  467.                              strcpy(remoteName, tableName);
  468.                              tblName = (pCHAR)tableName;
  469.                              isLocal = FALSE;
  470.                          }
  471.  
  472.                          if (tblName == NULL)
  473.                          {
  474.                              lastError = DBIERR_INVALIDTABLENAME;
  475.                              return FALSE;
  476.                          }
  477.  
  478.                          lastError = DbiOpenTableList(hDb, FALSE,
  479.                                                       TRUE,"*.*",
  480.                                                       &tabH);
  481.                          if (lastError != DBIERR_NONE)
  482.                          {
  483.                              return FALSE;
  484.                          }
  485.  
  486.                          lastError = DbiSetToBegin(tabH);
  487.                          if (lastError != DBIERR_NONE)
  488.                          {
  489.                              return FALSE;
  490.                          }
  491.  
  492.                          while ((DbiGetNextRecord(tabH,dbiNOLOCK,
  493.                                                  (pBYTE)&tblDesc,
  494.                                                  NULL))
  495.                                  == DBIERR_NONE)
  496.                          {
  497.                              if (!stricmp(tblDesc.szName,
  498.                                           tblName))
  499.                              {
  500.                                  // Check if the types match
  501.                                  if (strcmp(tblDesc.szType,
  502.                                             tableName) &&
  503.                                      (isLocal))
  504.                                  {
  505.                                      // keep searching it the
  506.                                      // table is of the wrong
  507.                                      // type
  508.                                      continue;
  509.                                  }
  510.                                  lastError = DBIERR_NONE;
  511.                                  DbiCloseCursor(&tabH);
  512.                                  return TRUE;
  513.                              }
  514.                          }
  515.  
  516.                          if (tabH)
  517.                          {
  518.                              DbiCloseCursor(&tabH);
  519.                          }
  520.  
  521.                          lastError = DBIERR_NOSUCHTABLE;
  522.  
  523.                          return exists;
  524.                      }
  525.  
  526. PXTblMaxSize()       DbiCreateTable(hDb, TRUE, &TblDesc);
  527.                      (This is done using the optional parameters
  528.                       in the table descriptor)
  529.  
  530. PXTblName()          DbiGetCursorProps(tabH, &CurProps);
  531.                      strcpy(szTblName, CurProps.szName);
  532.  
  533. PXTblNRecs()         DbiGetRecordCount(tabH, &iRecCount);
  534.                      (This function returns an approximation of
  535.                       the number of records in the table.)
  536.  
  537. PXTblOpen()          DbiOpenTable(hDb, szTblName, szPARADOX,
  538.                                   NULL, NULL, indexID,
  539.                                   dbiREADWRITE, dbiOPENSHARED,
  540.                                   xltFIELD, TRUE, NULL, &tabH);
  541.  
  542. PXTblProtected()     Not directly supported. For local tables,
  543.                      need to call DbiOpenTableList and get the
  544.                      information for that table.
  545.                      Example for use with 'C':
  546.                      BOOL isProtected(hDBIDb hDb,
  547.                                       const char *tableName,
  548.                                       const char *tableType)
  549.                      {
  550.                          BOOL        protect = FALSE;
  551.                          hDBICur     tabH    = 0;
  552.                          char        *tblName;
  553.                          TBLFullDesc  tblDesc;
  554.                          DBIResult   lastError;
  555.  
  556.                          // Different methodology required for
  557.                          // local and remote tables
  558.                          if ((!strcmp(tableType, szPARADOX)) ||
  559.                              (!strcmp(tableType, szDBASE)) ||
  560.                              (!strcmp(tableType, szASCII)))
  561.                          {
  562.                              tblName = _fstrtok((pCHAR)tableName,
  563.                                                 ".");
  564.                              if (tblName == NULL)
  565.                              {
  566.                                  lastError =
  567.                                          DBIERR_INVALIDTABLENAME;
  568.                                  return FALSE;
  569.                              }
  570.  
  571.                              lastError = DbiOpenTableList(hDb,
  572.                                                    TRUE, TRUE,
  573.                                                    "*.*", &tabH);
  574.                              if (lastError != DBIERR_NONE)
  575.                              {
  576.                                  return FALSE;
  577.                              }
  578.  
  579.                              lastError = DbiSetToBegin(tabH);
  580.                              if (lastError != DBIERR_NONE)
  581.                              {
  582.                                  return FALSE;
  583.                              }
  584.  
  585.                              while ((DbiGetNextRecord(tabH,
  586.                                                  dbiNOLOCK,
  587.                                                  (pBYTE)&tblDesc,
  588.                                                  NULL))
  589.                                      == DBIERR_NONE)
  590.                              {
  591.                                  if (!stricmp(
  592.                                           tblDesc.tblBase.szName,
  593.                                           tblName))
  594.                                  {
  595.                                      if (stricmp(
  596.                                           tblDesc.tblBase.szType,
  597.                                           tableType))
  598.                                      {
  599.                                          // Keep searching if the
  600.                                          // type doesn't match
  601.                                          continue;
  602.                                      }
  603.                                      if (
  604.                                         tblDesc.tblExt.bProtected
  605.                                         == TRUE)
  606.                                      {
  607.                                          // Table is protected
  608.                                          lastError = DBIERR_NONE;
  609.                                          DbiCloseCursor(&tabH);
  610.                                          return TRUE;
  611.                                      }
  612.                                      else
  613.                                      {
  614.                                          lastError = DBIERR_NONE;
  615.                                          DbiCloseCursor(&tabH);
  616.                                          return FALSE;
  617.                                      }
  618.                                  }
  619.                              }
  620.  
  621.                              if (tabH)
  622.                              {
  623.                                  DbiCloseCursor(&tabH);
  624.                              }
  625.  
  626.                              lastError = DBIERR_NOSUCHTABLE;
  627.                          }
  628.                          else
  629.                          {
  630.                              lastError = DbiOpenTable(hDb,
  631.                                                 (pCHAR)tableName,
  632.                                                 (pCHAR)tableType,
  633.                                                 NULL, NULL, NULL,
  634.                                                 dbiREADONLY,
  635.                                                 dbiOPENSHARED,
  636.                                                 xltNONE, FALSE,
  637.                                                 NULL, &tabH);
  638.                              if (lastError == DBIERR_NONE)
  639.                              {
  640.                                  DbiCloseCursor(&tabH);
  641.                                  protect = FALSE;
  642.                                  return protect;
  643.                              }
  644.                              else if (lastError ==
  645.                                       DBIERR_INVALIDPASSWORD)
  646.                              {
  647.                                  lastError = DBIERR_NONE;
  648.                                  protect = TRUE;
  649.                                  return protect;
  650.                              }
  651.                          }
  652.  
  653.                          return protect;
  654.                      }
  655.  
  656.  
  657. PXTblRename()        DbiRenameTable(hDb, szOldName, szTableType,
  658.                                     szNewName);
  659.  
  660. PXTblUpgrade()       DbiDoRestructure(hDb, 1, pTblDesc, pSaveAs,
  661.                                       NULL, NULL, FALSE);
  662.                      (Need to use the Optional Parameters to set
  663.                       the level of the table. Local tables only.)
  664.  
  665. PXWinInit()          DbiInit(NULL);
  666.                      DbiOpenDatabase(NULL, NULL, dbiREADWRITE,
  667.                                      dbiOPENSHARED, NULL, 0,
  668.                                      NULL, NULL, &hDb);
  669.