IBM Books

Image, Audio, and Video Extenders Administration and Programming


Enabling columns

Use the DBxEnableColumn API (where x is a for audio, i for image, or v for video) or the ENABLE COLUMN command to enable a column for a DB2 extender. When you issue the API or command, you specify the pertinent table and column.

When you enable a column, the extender adds information to the administrative support tables that belong to the user table. You need Control or Alter authority for the user table the column is in. Both the database and table must be enabled before you enable the column.

In the following examples, the PICTURE column in the EMPLOYEE table is enabled to hold image data. The database and table are already enabled.

Using the API: This example includes some error-checking code. The complete sample program is in the ENABLE.C file in the SAMPLES subdirectory.

Figure 12. Sample code that enables a column

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 ----*/

Using the db2ext command line: In this example, the column already exists, and the database and table are enabled.

enable column employee picture for db2image


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]