1. In SQL * Plus, SQL> Create Table t_photo1 (photo1 long raw); SQL> Create Table t_photo2 (photo2 long raw); 2. Hard Disk C: /open the form file tmp.bmp 3 and create two new blocks: t_photo1 and t_photo2 t_photo1 are database blocks. The connected table is a database table t_photo1 t_photo2 and also a database block, the connected table is the new image item t_photo2 (Backup table) t_photo1 in the database, named photo1, A new image item, named photo2, is created on the t_photo1 column t_photo2 in the t_photo1 table. It corresponds to create a button 1 in the photo2 column in The t_photo2 table and enter the following program, this button reads the image into the table, that is, entering the image into the table begin go_block ('t _ photo1 '); -- to block 1 read_image_file ('C:/tmp.bmp', 'bmp ', 't_photo1.photo1'); --read the external part tmp.bmp (image type: BMP) to the photo1 item of t_photo1, that is, to the t_photo1 table commit; -- save disk end; create a button 2, enter the following program. This button is used to implement an image inverted table (t_photo1 to t_photo2) Begin go_block ('t _ photo1); -- to block 1 execute_query; -- query the image in the table, at this time, the image in the table is written to the image item write_image_file ('C:/tmp.bmp ', 'bmp','t _ photo1.photo1 ') in the form; --you need to write the cursor into the external object tmp.bmp go_block ('t _ photo2 '); -- read Block 2 read_image_file ('C:/tmp.bmp ', 'bmp', 't_ photo2.photo2 '); --read the external file tmp.bmp to the photo2 item of the t_photo2 block, that is, commit in the t_photo2 table; -- save disk end; Note: t_photo1.photo1 is the image item in the official image table (Database item) (t_photo1 photo item 1) t_photo2.photo2 is the image item in the backup image table (Database item) (t_photo2 photo Item 2)
Appendix: An example of a button for saving an image to a database in the "open" dialog box
Declare str_filename varchar2 (200); str_filetype varchar2 (3); beginstr_filename: = get_file_name ('C:/', 'graphic file', 'bmp _ file (*. BMP) | *. BMP | '| 'jpg _ file (*. JPG) | *. JPG | 'GIF _ file (*. GIF) | *. GIF | '| 'tif _ file (*. TIF) | *. TIF | ',' select the image file to be saved to the database: ', open_file, true); str_filetype: = substr (str_filename, length (str_filename)-2, 3 ); go_block ('photo _ test'); execute_query; last_record; -- move to the last record next_record; -- move to the next record, that is, a new record Read_image_file (str_filename, str_filetype, 'photo _ test. photo '); If str_filename is not null then commit; end if; end; Note: photo_test is the data block, and photo_test.photo is the data item of the Lang raw field in the corresponding database in the data block.