IBM Books

Image, Audio, and Video Extenders Administration and Programming


Finding files referenced by table entries

Use the DBxAdminGetReferencedFiles API or the GET REFERENCED FILES command to list the external media files that are referred to by all or a subset of the user tables in the current database. Use the DBxGetReferencedFiles API or the GET REFERENCED FILES command to list the external media files that are referenced in a specific table.

Using the API: The sample code in the following example returns the number of files it finds and a list of the files. The complete sample program is in the API.C file in the SAMPLES subdirectory.

Figure 15. Sample code that gets a list of referenced files

/*---- Query the database using DBiAdminGetReferencedFiles API. ----------*/
step="DBiAdminGetReferencedFiles API"
rc = DBiAdminGetReferencedFiles((char*) uid, &count, &filelist);
if (rc < 0) {
   printf("%s: %s FAILED!\n", program, step);
   printMsg(rc);
   DBiGetError(&sqlcode, errorMsgText);
   printf{"sqlcode=%i, errorMsgText=%s\n", sqlcode, errorMsgText);
} else if (rc > 0) {
   printf("%s: %s, warning detected.\n", program, step);
   printMsg(rc);
   DBiGetError(&sqlcode, errorMsgText);
   printf("sqlcode=%i, errorMsgText=%s\n", sqlcode, errorMsgText);
} else {
   if (count == 0)
     printf("%s: no referenced files\n", program);
  else {
     printf("%s: %d referenced files\n", program, count);
     for (i=0; i < count; i++)
       {
   printf ("filename = %s\n", filelist[i].filename);
   printf ("\tqualifier = %s\n", filelist[i].tqualifier);
   printf ("\ttable = %s\n", filelist[i].tname);
   printf ("\thandle = %s\n", filelist[i].handle);
   printf ("\tcolumn = %s\n", filelist[i].column);
       if (filelist[i].filename)
               free (filelist[i].filename);
     }
   }
   if (filelist)
       free (filelist);
   printf("%s: %s PASSED\n\n", argv[0], step);
}

Using the db2ext command line:

get referenced files user anitas for db2image


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