IBM Books

Image, Audio, and Video Extenders Administration and Programming

DB2Audio


Image Audio Video
  X  

Stores the content of an audio in a database table. The audio source can be in a client buffer, client file, or server file. The audio can be stored in the database table as a BLOB, or in a server file (referred to by the database table). The audio source can be in a supported format, in which case, the DB2Audio Extender identifies its attributes for storage, or in an unsupported format, in which case the attributes must be specified in the UDF.

Include file

dmbaudio.h

Syntax

Store content from buffer or client file

>>-DB2Audio--(--dbname--,--content--,--format--,---------------->
 
>----target_file--,--comment--)--------------------------------><
 

Syntax

Store content from server file

>>-DB2Audio--(--dbname--,--source_file--,--format--,--stortype--,-->
 
>---comment--)-------------------------------------------------><
 

Syntax

Store content with user-supplied attributes from buffer or client file

>>-DB2Audio--(--dbname--,--content--,--target_file--,----------->
 
>----comment--,--attrs--)--------------------------------------><
 

Syntax

Store content with user-supplied attributes from server file

>>-DB2Audio--(--dbname--,--source_file--,--stortype--,--comment--,-->
 
>---attrs--)---------------------------------------------------><
 

Parameters (data type)

dbname (VARCHAR(18))
The name of the currently connected database, as indicated by the CURRENT SERVER special register.

content (BLOB(2G) AS LOCATOR)
The host variable that contains the content of the audio. The host variable can be of type BLOB, BLOB_FILE, or BLOB_LOCATOR. DB2 promotes the data type of the content to BLOB-LOCATOR and passes the LOB locator to the DB2Audio UDF.

format (VARCHAR(8))
The format of the source audio. A null value or empty string can be specified, in which case the Audio Extender will attempt to determine the source format automatically. The audio will be stored in the same format as its source. See Table 4 for supported audio formats.

target_file (LONG VARCHAR)
The name of the target server file (for storage to a server file), or a null value or empty string (for storage into a database table as a BLOB). The target file can be a fully qualified name. If the name is unqualified, the DB2AUDIOSTORE and DB2MMSTORE environment variables on the server are used to locate the file.

source_file (LONG VARCHAR)
The name of the source server file. The source file name can be a fully qualified name or an unqualified name; it cannot be a null value or empty string. If the name is unqualified, the DB2AUDIOPATH and DB2MMPATH environment variables on the server will be used to locate the file.

stortype (INTEGER)
A value that indicates where the audio will be stored. The constant MMDB_STORAGE_TYPE_INTERNAL (value=1) indicates that the audio will be stored in the database as a BLOB; the constant MMDB_STORAGE_TYPE_EXTERNAL (value=0) indicates that the audio content will be stored in a server file (pointed to from the database).

comment (LONG VARCHAR)

A comment to be stored with the audio.

attrs (LONG VARCHAR FOR BIT DATA)
The attributes of the audio.

Return values (data type)

Handle of the audio (DB2AUDIO)

Examples

Insert a record that includes an audio clip for Anita Jones into the employee table. The audio source is in a client buffer. Store the audio clip in the table as a BLOB:

EXEC SQL BEGIN DECLARE SECTION;
     SQL TYPE IS BLOB (5M) aud_seg;
EXEC SQL END DECLARE SECTION;
 
EXEC SQL INSERT INTO EMPLOYEE VALUES(
      '128557',
      'Anita Jones',
      DB2AUDIO(
         CURRENT SERVER,
         :aud_seg,
         'WAVE',
         CAST(NULL as LONG VARCHAR),
         
         'Anita''s voice'));

Insert a record that includes an audio clip for Robert Smith into the employee table. The audio source is in a server file. The employee table record will point to the file.

EXEC SQL BEGIN DECLARE SECTION;
     long hvStorageType;
EXEC SQL END DECLARE SECTION;
 
hvStorageType = MMDB_STORAGE_TYPE_EXTERNAL;
 
EXEC SQL INSERT INTO EMPLOYEE VALUES(
      '384779',
      'Robert Smith',
      DB2AUDIO(
         CURRENT SERVER,
         '/employee/sounds/rsmith.wav',
         'WAV',
         :hvStorageType,
         'Robert''s voice'));

Insert a record that includes an audio clip for Anita Jones into the employee table. Store the audio clip as a BLOB. The source audio clip, which is in a server file, has a user-defined format, a sampling rate of 44.1 KHz, and has two recorded channels.

EXEC SQL BEGIN DECLARE SECTION;
long hvStorageType;
struct {
       short len;
       char data[600];
}hvAudattr;
EXEC SQL END DECLARE SECTION;
 
MMDBAudioAttrs          *paudiattr;
 
hvStorageType = MMDB_STORAGE_TYPE_INTERNAL;
 
paudioattr=(MMDBAudioAttrs *) hvAudattr.data;
strcpy(paudioAttr>cFormat,"cFormatA");
paudioAttr>ulSamplingRate=44100;
paudioAttr>usNumChannels=2;
hvAudattrs.len=sizeof(MMDBAudioAttrs);
 
EXEC SQL INSERT INTO EMPLOYEE VALUES(
        '128557',
        'Anita Jones',
               DB2AUDIO(
               CURRENT SERVER,
               '/employee/sounds/ajones.aud',
               :hvStorageType,
               'Anita"s voice',
               :hvAudattr)
       );


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