|
|
Re: How to work with picts in oracle/forms [message #82256 is a reply to message #82253] |
Wed, 14 May 2003 01:48  |
 |
Maaher
Messages: 7065 Registered: December 2001
|
Senior Member |
|
|
If it was my choice: I would go for a BLOB, LONGs and LONGRAWs are limited in accessibility (e.g. through Java).
Anyway, you create a database block based on the following table
PIC_TABLE
---------
PIC_ID NUMBER
PIC_CONTENT LONG_RAW/BLOB -- whatever suits you Next, you create the form items, just like you normally do, but for the PIC_CONTENT item, you change the Item Type property into Image. You need to say what file type this image of yours is (TIFF, GIF, ...). Let's say GIF.
The third step is to create a button to select the image you want to store. Put code like this in the buttons' WHEN-BUTTON-PRESSED:Declare
filename VARCHAR2(256);
Begin
filename := GET_FILE_NAME(File_Filter=> 'GIF Files (*.gif)|*.gif|');
READ_IMAGE_FILE(filename, 'GIF', 'pics.pic');
END; For deletion, create another button with code like this:Begin
GO_ITEM('pics.pic');
CLEAR_ITEM;
END; It seems to me that it doesn't work with long raws though. Here's an alternative, more code but works like a charm (even for LONG RAWs):DECLARE
curritem VARCHAR2(20);
formname VARCHAR2(20) := :SYSTEM.CURRENT_FORM;
BEGIN
curritem := GET_BLOCK_PROPERTY(:SYSTEM.CURRENT_BLOCK, FIRST_ITEM);
-- create a record to duplicate the items
create_record ;
-- disable validation in form
SET_FORM_PROPERTY(formname,VALIDATION,PROPERTY_FALSE);
-- loop through all items in a block and skip image item
WHILE curritem IS NOT NULL LOOP
IF GET_ITEM_PROPERTY(curritem,ITEM_TYPE)!= 'IMAGE' THEN
GO_ITEM(curritem);
DUPLICATE_ITEM;
ELSE -- now, don't 'duplicate' image item
null;
END IF;
curritem := GET_ITEM_PROPERTY(curritem,NEXTITEM);
END LOOP;
-- delete the original record
PREVIOUS_RECORD;
delete_record ;
-- restore validation in form
SET_FORM_PROPERTY(formname,VALIDATION,PROPERTY_TRUE);
END; HTH,
MHE
|
|
|