Solved

Displaying Size of image in Oracle Forms

Posted on 2014-01-11
3
548 Views
Last Modified: 2014-01-19
i m using get_file_name built-in on when-button-pressed trigger and save image in database BLOB datatype, every thing is going smoothly but i have a requirement that if load size is more then 25 kb then user unable to save this image with
message ('Image Size is more then 25kb ');

i got some online help can any one exaplain me this code

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

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;  
SELECT photo   INTO dst_file  FROM temp_photo  WHERE id = p_id  AND photo_name = p_photo_name  FOR UPDATE;  
dbms_lob.fileopen(src_file, dbms_lob.file_readonly);  
lgh_file := dbms_lob.getlength(src_file);
dbms_lob.loadfromfile(dst_file, src_file, lgh_file);
UPDATE temp_photo   SET photo = dst_file  WHERE id = p_id  AND photo_name = p_photo_name;

 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


Thanks in advance
0
Comment
Question by:hinamansoor
  • 2
3 Comments
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 39774135
Look like either you define a database directory named PHOTO_DIR that points to the proper folder pointed to by PHOTO_DIR doesn't contain a file called Sunset.jpg.

The online docs have the information about creating directories and about  dbms_lob.loadfromfile.

Create directory:
http://docs.oracle.com/cd/E11882_01/server.112/e41084/statements_5007.htm#SQLRF01207

dbms_lob.loadfromfile:
http://docs.oracle.com/cd/E11882_01/appdev.112/e40758/d_lob.htm#ARPLS66733

As for the code itself, I think there are several unnecessary steps involved.  There are several examples on the the web if you look around.

Personally I would change the procedure call and go with:
dbms_lob.LOADBLOBFROMFILE

http://docs.oracle.com/cd/E11882_01/appdev.112/e40758/d_lob.htm#ARPLS66723

Google around for LOADBLOBFROMFILE and you'll  locate many examples.
0
 

Accepted Solution

by:
hinamansoor earned 0 total points
ID: 39779527
i have solved this issue by using

"Win_API_File.File_Size"


Thanks for all
0
 

Author Closing Comment

by:hinamansoor
ID: 39791920
i have solved this issue by using

Win_API_File.File_Size
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now