Image、Audio 及 Video Extenders 管理與程式設計


啟用直欄

使用 DBxEnableColumn API (其中 x 若是 a 代表音效,i 代表 影像,或 v 代表視訊) 或使用 ENABLE COLUMN 指令,以啟用 DB2 Extender 的直欄。 發出 API 或指令時,請指定所屬的表格和直欄。

啟用直欄時,Extender 會新增資訊至屬於使用者表格的管理支援表格內。對於含有此直欄的使用者表格來說,您需要「控制」權限或「變更」權限。必須啟用資料庫和表格之後才能啟用直欄。

下列範例中,啟用員工表格中的圖片直欄來保留影像資料。資料庫和表格已經啟用。

使用 API:本範例包括一些錯誤檢查碼。 完整範例程式位於 SAMPLES 次目錄中的 ENABLE.C 檔。

圖 12. 啟用直欄的範例程式碼

        char imageColumn[18+1] = "covers";
 
/*---- enable column for image extender ----*/
     printf("%s: Enabling columns......\n", program);
step="DBiEnableColumn";
     rc = DBiEnableColumn(tableName, imageColumn);
if (rc < 0) {
                printf("%s: %s failed!\n", program, step);
   printMsg(rc);
        DBiGetError(&sqlcode, errorMsgText);
           if (sqlcode)
              printf("sqlcode=%i, ", sqlcode);
           printf("errorMsgText=%s\n", errorMsgText)
          
} else if (rc > 0) {
           printf("%s: %s, warning detected.\n", program, step);
   printMsg(rc);
        DBiGetError(&sqlcode, errorMsgText);
           printf("warningMsgText=%s\n", errorMsgText);
     } else
           printf("%s: %s OK\n", program, step);
/*---- enable column for image extender ----*/

使用 db2ext 指令行:在本範例中,此直欄已存在,而且已啟用資料庫 和表格。

enable column employee picture for db2image


[ 頁面頂端 | 前一頁 | 下一頁 | 目錄 | 索引 ]