An account manager in the advertising agency needs to see the video advertisements created for the IBM account in 1997, but only advertisements whose duration is 30 seconds or less.
The following figure shows a query that accesses the videos. Notice that the Video Extender UDFs named Filename and Duration in the query.
Figure 2. A query that accesses videos
SELECT FILENAME(ADS_VIDEO) FROM ADS WHERE CLIENT='IBM' AND SHIP_DATE>='01/01/1997' AND DURATION(ADS_VIDEO) <=30 |
The query returns the file names of the desired videos. The account manager can then start his favorite video player and play the content of each video file.
The previous example illustrates a query that the account manager can issue interactively. More typically, the account manager would use an application program to find and play videos. The following example shows some key elements of such an application coded in C. The application retrieves the video file names in a DB2 host variable named hvVid_fname. Also notice that the application uses a play API, named DBvPlay, to play the videos.
Figure 3. An application that accesses and plays videos
#include <dmbvideo.h> int count = 0; EXEC SQL BEGIN DECLARE SECTION; char hvClient[30]; /*client name*/ char hvCampaign[30]; /*campaign name*/ char hvSdate[8]; /*ship date*/ char hvVid_fname [251] /*video file name*/ EXEC SQL END DECLARE SECTION; EXEC SQL DECLARE c1 CURSOR FOR SELECT CLIENT, CAMPAIGN, SHIP_DATE, FILENAME(ADS_VIDEO) FROM ADS WHERE CLIENT='IBM' AND SHIP_DATE>='01/01/1997' AND DURATION(ADS_VIDEO)<=30 FOR FETCH ONLY; EXEC SQL OPEN c1; for (;;){ EXEC SQL FETCH c1 INTO :hvClient, :hvCampaign, :hvSdate, :hvVid_fname; if (SQLCODE != 0) break; printf("\nRecord %d:\n", ++count); printf("Client = '%s'\n", hvClient); printf("Campaign = '%s'\n", hvCampaign); printf("Sdate = '%s'\n", hvSdate); rc=DBvPlay(NULL,MMDB_PLAY_FILE,hvVid_fname,MMDB_PLAY_WAIT); } EXEC SQL CLOSE c1; |