用户为 Anita Jones 将一条记录插入 Employee 表中。该记录包括 Anita 的 ID (128557)、姓名、照片和录音。源图象和音频内容在服务器上的文件中。图象以 BLOB 形式存储在表中;音频的内容仍在服务器文件中(表项引用服务器文件)。
用户的工作:用户使用包括语句的应用程序来在 employee 表中插入记录,这些语句显示在下例中。
EXEC SQL BEGIN DECLARE SECTION; long hvInt_Stor; long hvExt_Stor; EXEC SQL END DECLARE SECTION; hvInt_Stor = MMDB_STORAGE_TYPE_INTERNAL; hvExt_Stor = MMDB_STORAGE_TYPE_EXTERNAL; EXEC SQL INSERT INTO EMPLOYEE VALUES( '128557', /*id*/ 'Anita Jones', /*name*/ DB2IMAGE( /*Image Extender UDF*/ CURRENT SERVER, /*database server name in*/ /CURRENT SERVER register*/ '/Employee/images/ajones.bmp' /*image source file*/ 'ASIS', /*keep the image format*/ :hvInt_Stor, /*store image in DB as BLOB*/ 'Anita''s picture'), /*comment*/ DB2AUDIO( /*Audio Extender UDF*/ CURRENT SERVER, /*database server name in*/ /*CURRENT SERVER register*/ '/Employee/Sounds/ajones.wav', /*audio source file*/ 'WAVE', /* audio format */ :hvExt_Stor, /*retain content in server file*/ 'Anita''s voice') /*comment*/ ); |
发生的情况 作为对 INSERT 语句中的 DB2Image UDF 的响应, Image Extender:
图象源是名为 ajones.bmp 的服务器文件。将该文件的内容以 BLOB 形式插入管理支持表记录中。存储的图象的格式与源图象相同; 不进行格式转换。
作为对 INSERT 语句中的 DB2Audio UDF 的响应,Audio Extender:
音频内容在名为 ajones.wav 的服务器文件中;管理支持表记录引用此文件。
触发器将图象和音频属性数据插入到各种管理支持表中。