1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Loading images into Oracle Forms

Discussion in 'Oracle Forms and Reports' started by robin, Feb 3, 2012.

  1. robin

    robin Forum Advisor

    Messages:
    55
    Likes Received:
    7
    Trophy Points:
    160
    Location:
    Hyderabad
    Hi,

    I have an image in D:\image\Sunset.jpeg

    I want to load this image into Oracle form so I created an Image Item in Oracle form and wrote the following code in When_Image_Pressed trigger

    Code (Text):
    READ_IMAGE_FILE('D:\image\Sunset.jpeg','jpeg','IMAGE48');
    IMAGE48 is the item name(Image item)

    I run the form and when I click on the image item I get the following error msg :

    Cannot locate image file D:\image\Sunset.jpeg

    Should we store images in the server only ?

    I googled for the solution and did this :


    I created a directory using SQL *Plus as

    create directory photo_dir as 'D:\image';


    A table as


    Code (SQL):
    CREATE TABLE TEMP_PHOTO ( ID NUMBER(3) NOT NULL, PHOTO_NAME VARCHAR2(50), PHOTO BLOB );

    Then the Procedure :



    Code (SQL):
    CREATE OR REPLACE PROCEDURE load_file ( p_id NUMBER, p_photo_name IN varchar2)
    IS  
    src_file BFILE;
    dst_file BLOB;
    lgh_file BINARY_INTEGER;  
    BEGIN  
    src_file := bfilename('PHOTO_DIR', p_photo_name);
      -- insert a NULL record to lock
     INSERT INTO temp_photo  (id, photo_name, photo)  VALUES  (p_id , p_photo_name ,EMPTY_BLOB())  RETURNING photo INTO dst_file;  
    -- lock record  
    SELECT photo   INTO dst_file  FROM temp_photo  WHERE id = p_id  AND photo_name = p_photo_name  FOR UPDATE;  
    -- open the file  
    dbms_lob.fileopen(src_file, dbms_lob.file_readonly);  
     -- determine length
     lgh_file := dbms_lob.getlength(src_file);
      -- read the file  
    dbms_lob.loadfromfile(dst_file, src_file, lgh_file);
      -- update the blob field  
    UPDATE temp_photo   SET photo = dst_file  WHERE id = p_id  AND photo_name = p_photo_name;
      -- close file
     dbms_lob.fileclose(src_file);  
    END load_file;
     
    The procedure created successfully

    Now,

    execute load_file(1,'Sunset.jpg'); gives me the following error :

    ERROR at line 1:
    ORA-22288: file or LOB operation FILEOPEN failed
    No such file or directory
    ORA-06512: at "SYS.DBMS_LOB", line 805
    ORA-06512: at line 6



    What is the problem here ? I created the directory successfully.


    Thanks in advance,
    Robin
     
    gurujothi and Ramji like this.
  2. Ramji

    Ramji Forum Guru

    Messages:
    525
    Likes Received:
    177
    Trophy Points:
    1,505
    Location:
    Nomad
    Robin,

    Try Load some Proscribed Photo LOL. Wondering if Oracle has any Child Protection stuff In built. Oracle is FASB Compliant. Maybe you could take it up with Oracle Development and win accolades for developing Porno Proofing into the software.

    Just in Lighter Vein. Thanks for sharing
    cheers
    Ramji
     
  3. Sadik

    Sadik Community Moderator Forum Guru

    Messages:
    1,906
    Likes Received:
    252
    Trophy Points:
    1,455
    I think Robin was asking help with the error Ramji...
     
    Ramji likes this.
  4. Ramji

    Ramji Forum Guru

    Messages:
    525
    Likes Received:
    177
    Trophy Points:
    1,505
    Location:
    Nomad
    Dear Sadikbhai,

    I know. Please note the ''Just in Lighter vein''. I was multitasking and saw the post. Just wanted to lighten up things I aired the ludicrous thoughts that forced a smile in me. No intention of belittling his query. I am sure you will not mind the lighter side of this serious pursuit we indulge in.

    I am sure some of our Technical Hands on members will sure help with his query. PM me on your thoughts. I shall follow without any issues.
    Best Regards,
    Ramji
     
  5. Sadik

    Sadik Community Moderator Forum Guru

    Messages:
    1,906
    Likes Received:
    252
    Trophy Points:
    1,455
    Hey venky... no problems... I too love the lighter vein... :)
     
  6. robin

    robin Forum Advisor

    Messages:
    55
    Likes Received:
    7
    Trophy Points:
    160
    Location:
    Hyderabad
    I got it.In the Image Item Properties -Image Format there is no jpeg format.I changed this to tiff and loaded a tiff image.It's working fine.No big code here just a simple single line;

    READ_IMAGE_FILE('D:\image\Sunset.tiff,'tiff','IMAGE48');

    A very small basic mistake.........
     
    Sadik likes this.
  7. Ramji

    Ramji Forum Guru

    Messages:
    525
    Likes Received:
    177
    Trophy Points:
    1,505
    Location:
    Nomad
    Robin,

    You are ready to take on the world now!!!!!!!!
    For Life and wife m8.

    ''Very small basic mistake'' is often the root cause(technically speaking) of new life.

    You are now ready for life ! Good Luck :)
    cheers
    Ramji
     
  8. rajavu

    rajavu Forum Guru

    Messages:
    815
    Likes Received:
    52
    Trophy Points:
    610
    Location:
    @ Bangalore , India
    And btw, Oracle Directories can be created only in the Server directory and non at client side.
     
  9. Ramji

    Ramji Forum Guru

    Messages:
    525
    Likes Received:
    177
    Trophy Points:
    1,505
    Location:
    Nomad
    Rajavu,

    Enhancement on the way. All sides possible. Did you read the news? A man had a sex change operation and delivered a baby in UK. Fusion Plus could go that way LOL
    cheers
    Ramji
     
  10. aclink

    aclink Active Member

    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    55
    never heard of that,