C Examples: DbiCreateTempTable

<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«

C Examples: DbiCreateTempTable

Return to chapter overview

Example 1: Create a temporary table using IDAPI logical types in the field descriptor.

The temporary table can be made permanent later on. This example uses the following input:
         fDbiCreateTempTable1(hDb, &hTmpCur);

DBIResult fDbiCreateTempTable1(hDBIDb hTmpDb, phDBICur phTmpCur)

{

   CHAR             szTblName[] = "TempPXTbl";

   CRTblDesc      TblDesc;    // Create Table Descriptor

   DBIResult        rslt;

   UINT16           NumFields  = 2;

   FLDDesc          fldDesc[] = {

            {     // Field 1 - ALPHA

               1, "MyAlpha", fldZSTRING, fldUNKNOWN, 10, 0,

               0, 0, 0, fldvNOCHECKS, fldrREADWRITE

            },

            {     // FIELD 2 - NUMERIC

               2, "MyNumber", fldFLOAT, fldUNKNOWN, 0, 0, 0,

               0, 0, fldvNOCHECKS, fldrREADWRITE

            }

   };

   memset((void *) &TblDesc, 0, sizeof(CRTblDesc));

   lstrcpy(TblDesc.szTblName, szTblName);

   lstrcpy(TblDesc.szTblType, szPARADOX);

   TblDesc.iFldCount = NumFields;

   TblDesc.pfldDesc = fldDesc;

   //Could add indexes, validity checks, and security descriptors here.

   rslt = Chk(DbiCreateTempTable(hTmpDb, &TblDesc, phTmpCur));

   return rslt;

}

 

Example 2: Create a temporary table using dBASE physical types in the field descriptor.

The temporary table can be made permanent later on. This example uses the following input:
         fDbiCreateTempTable2(hDb, &hTmpCur);

DBIResult fDbiCreateTempTable2(hDBIDb hTmpDb, phDBICur phTmpCur)

{

   CHAR             szTblName[] = "TempdBASETbl";

   CRTblDesc        TblDesc;    // Create Table Descriptor

   DBIResult        rslt;

   UINT16           NumFields  = 2;

   FLDDesc          fldDesc[] = {

            {      // Field 1 - MEMO

               1, "MyAlpha", fldDBMEMO, fldUNKNOWN, 0, 0,

               0, 0, 0, fldvNOCHECKS, fldrREADWRITE

            },

            {      // FIELD 2 - BOOLEAN

               2, "MyNumber", fldDBBOOL, fldUNKNOWN, 0, 0, 0,

               0, 0, fldvNOCHECKS, fldrREADWRITE

            }

   };

   memset((void *) &TblDesc, 0, sizeof(CRTblDesc));

   lstrcpy(TblDesc.szTblName, szTblName);

   lstrcpy(TblDesc.szTblType, szDBASE);

   TblDesc.iFldCount = NumFields;

   TblDesc.pfldDesc = fldDesc;

   //Could add indexes, validity checks, and security descriptors here.

   rslt = Chk(DbiCreateTempTable(hTmpDb, &TblDesc, phTmpCur));

   return rslt;

}