Home » Developer & Programmer » Forms » How to work with picts in oracle/forms
How to work with picts in oracle/forms [message #82249] Tue, 13 May 2003 23:35 Go to next message
BIRENDER KUMAR
Messages: 18
Registered: May 2003
Junior Member
How to work with picts in oracle/forms
I have created a table with a col as long datatype.
How can I insert/update/delete/query thru forms(front-end).
Re: How to work with picts in oracle/forms [message #82253 is a reply to message #82249] Wed, 14 May 2003 00:30 Go to previous messageGo to next message
Mubeen
Messages: 44
Registered: February 2003
Member
As far as my knowledge is concern

the solution for your first query is, instead of creating a column to store images(picts)by using long datatype,create a column with longraw datatype,which is used to store images.
Re: How to work with picts in oracle/forms [message #82256 is a reply to message #82253] Wed, 14 May 2003 01:48 Go to previous message
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)&#124*.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
Previous Topic: conversion of a developer's report output into .pdf file
Next Topic: Oracle forms
Goto Forum:
  


Current Time: Fri Apr 19 01:03:57 CDT 2024