Oracle Forms Additional techniques • Using a form called 'Art Pictures' to show the use of images. • Also, how to set the colour of a form dynamically depending on the mode it is in. Download the artpictures.fmb form from the module website and you can look at it carefully so see how it works. These lecture notes are an overview of that. You can apply the techniques to your own forms if you want.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Oracle Forms
Additional techniques
• Using a form called 'Art Pictures' to show the use of images.
• Also, how to set the colour of a form dynamically depending on the mode it is in.
Download the artpictures.fmb form from the module website and you can look at it
carefully so see how it works. These lecture notes are an overview of that. You can apply the
techniques to your own forms if you want.
Create a table to hold the images...
Créate the following table:
create table pics(pic1 long raw, pic_label varchar2(3 0)); Table
created.
'Long Raw' is the data type used to hold the image. When you look at it in SQL it will just show some spurious
characters.
The same folder viewed as a list...
Steps to import a file.
1 Enter file name e.g. 'Clock'
2. Enter file path e.g. 'X\Gary Budgen\images\ (there is a list in the form)
3. Enter file type (there is a list of valid types in the form)
Step 4. Press the 'Get' button...
Pressing the save button will save the picture to the database. The
name specified in the 'Name of Picture' will be what is saved in the database
table along with the picture.
-
PROCEDURE get_imageIS
/* Define the local variables*/ This is the procedure that gets thel_filename VARCHAR2(60); l_type VARCHAR2(10);
l_item_nameVARCHAR2(60);
variables the values specified inLpathVARCHAR2(60); the form and then calls a built-in
BEGIN
/* Assign the values of the fields to the variables*/ procedure calledl_filename:= :PICS.file_image; 'read_image_file' l_type:= :PICS.type; read_image_file
l_path := :PICS.file_path; which retrieves the files.
/* Assign the variable of the item where the picture will be put in the form*/ l_item_name :=
'PICS.pic1';
/* Define the filename as the path, actual name of the file and the type of file, but concatenating
the various elements from the variables*/
l_filename := l_path||l_filename||'.'||l_type;
/*Use the build in procedure READ_IMAGE_FILE to retrieve the image from
Fill in the Destination File, i.e. create a name here for a file where the picture will be saved.
Saving a picture already in your database to a file.
1. Fill in the File Path
2. Fill in the File Type
9S3SB3B3930BD3
Check it is in the file system, you can check the time and date...
"SI
PROCEDURE write_image S /* Define the variables*/ l_filename VARCHAR2(50); l_path VARCHAR2(30);l_compression VARCHAR2(30);l_type VARCHAR2(5);l_image_depth VARCHAR2(30);BEGIN
/* Assign the values in the form to the variables*/ l_filename := :PICS.destination_file; l_path := :PICS.file_path l_type := :PICS.type;l_filename := l_path||l_filename||'.'||l_type;l_compression := :PICS.compression; l_image_depth := :PICS.image_depth;/* Check the image depth, if none specified then just use the default*/ IF l_image_depth = 'MONOCHROME THENWRITEJMAGE_FILE(l_filename,:PICS.type/PICS.PIC1\NO_COMPRESSION,MONOCHROME);ELSIF l_compression = 'MAXIMIZE_COMPRESSION' THEN WRITEJMAGE_FILE(Lfilename,:PICS.type/PICS.PIC1',MAXIMIZE_COMPRESSION,MONOCHROME);ELSE/* Use the default*/ END IF;