C Examples: DbiGetProp

<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«

C Examples: DbiGetProp

Return to chapter overview

Example 1: Get the native database handle from a remote database:

This example uses the following input:
         fDbiGetProp1(hDb, &hIBDb);

DBIResult fDbiGetProp1(hDBIDb hTmpDb, pUINT32 hRemoteDb)

{

   DBIResult   rslt;

 

   rslt = Chk(DbiGetProp((hDBIObj)hTmpDb, dbNATIVEHNDL, (pBYTE)hRemoteDb,

               sizeof(dbNATIVEHNDL), NULL));

   return rslt;

}

 

Example 2: Return a string containing information about the specified table:

Note: pCursorInfo must be large enough to hold data. This example uses the following input:
         char   Buffer[500];
         fDbiGetProp2(hCur, Buffer);

DBIResult fDbiGetProp2(hDBICur hTmpCur, pCHAR pCursorInfo)

{

   DBIResult   rslt;

   CHAR        Buffer[500];

   INT16       Level;

 

   strcpy(pCursorInfo, "\0");

   // Get the table name.

   rslt = Chk(DbiGetProp((hDBIObj)hTmpCur, curTABLENAME, (pBYTE)Buffer,

                     DBIMAXTBLNAMELEN, NULL));

   if (rslt != DBIERR_NONE)

      return rslt;

   wsprintf(pCursorInfo, "%s\r\nTable Name: %s", pCursorInfo, Buffer);

 

   // Get the table type.

   rslt = Chk(DbiGetProp((hDBIObj)hTmpCur, curTABLETYPE, (pBYTE)Buffer,

                     DBIMAXNAMELEN, NULL));

   if (rslt != DBIERR_NONE)

      return rslt;

   wsprintf(pCursorInfo, "%s\r\nTable Type: %s", pCursorInfo, Buffer);

 

   // Get the full file name.

   rslt = Chk(DbiGetProp((hDBIObj)hTmpCur, curFILENAME, (pBYTE)Buffer,

                     DBIMAXPATHLEN, NULL));

   if (rslt != DBIERR_NONE)

      return rslt;

   wsprintf(pCursorInfo, "%s\r\nFile Name: %s", pCursorInfo, Buffer);

 

   // Get the table level.

   rslt = Chk(DbiGetProp((hDBIObj)hTmpCur, curTABLELEVEL, (pBYTE)&Level,

                     sizeof(curTABLELEVEL), NULL));

   if (rslt != DBIERR_NONE)

      return rslt;

   wsprintf(pCursorInfo, "%s\r\nTable Level: %d", pCursorInfo, Level);

 

   return rslt;

}

 

Example 3: Return a string containing information about the specified SQL database:  

Note: pCursorInfo must be large enough to hold data. This example uses the following input:
         char   Buffer[500];
         fDbiGetProp3(hCur, Buffer);

DBIResult fDbiGetProp3(hDBIDb hTmpDb, pCHAR pDBInfo)

{

   DBIResult   rslt;

   BOOL        b;

   UINT16      i;

 

   strcpy(pDBInfo, "\0");

 

   // Does the Database support Asyncronous Query Execution support?

   rslt = Chk(DbiGetProp((hDBIObj)hTmpDb, dbASYNCSUPPORT, (pBYTE)&b,

                     sizeof(b), NULL));

   if (rslt != DBIERR_NONE)

      return rslt;

   if (b == TRUE)

      wsprintf(pDBInfo, "%s\r\nAsync. query exec support: TRUE", pDBInfo);

   else

      wsprintf(pDBInfo, "%s\r\nAsync. query exec support: FALSE", pDBInfo);

 

   // Does the Database support Stored Procedures?

   rslt = Chk(DbiGetProp((hDBIObj)hTmpDb, dbPROCEDURES, (pBYTE)&b,

                     sizeof(b), NULL));

   if (rslt != DBIERR_NONE)

      return rslt;

   if (b == TRUE)

      wsprintf(pDBInfo, "%s\r\nStored Procedure support: TRUE", pDBInfo);

   else

      wsprintf(pDBInfo, "%s\r\nStored Procedure support: FALSE", pDBInfo);

 

   // What is the major server version?

   rslt = Chk(DbiGetProp((hDBIObj)hTmpDb, dbSERVERVERSION, (pBYTE)&i,

                     sizeof(i), NULL));

   if (rslt != DBIERR_NONE)

      return rslt;

   wsprintf(pDBInfo, "%s\r\nMajor server version: %d", pDBInfo, i);

 

   return rslt;

}