Link to home
Start Free TrialLog in
Avatar of cookiejar
cookiejarFlag for United States of America

asked on

ORACLE 10G - Update blob field with a jpeg

What is the syntax to update a blob field in ORACLE 10 g
For example:
Update table.blobfield with e:\jpegfile where table.keyid = '5'
ASKER CERTIFIED SOLUTION
Avatar of danrudolph
danrudolph
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cookiejar

ASKER

I am definitely a novice, could you please explain bfilename('GIF_FILES','APRIL.JPG'),'JPEG')?  How should I update if the record already exists and I want to update with an updated jpeg.  Do I have to delete and use the INSERT?
CREATE TABLE imagetab
(imagfile BLOB);


TABLE created.

scott@ORA92> CREATE OR REPLACE DIRECTORY imagefiles AS 'd:\oracle'

2 /

DIRECTORY created.

DECLARE
v_bfile BFILE;
v_blob BLOB;
BEGIN
INSERT INTO imagetab (imagfile)
VALUES (EMPTY_BLOB())
RETURN imagfile INTO v_blob;
v_bfile := BFILENAME ('IMAGEFILES', 'p.bmp');
Dbms_Lob.fileopen (v_bfile, Dbms_Lob.File_Readonly);
Dbms_Lob.Loadfromfile (v_blob, v_bfile, Dbms_Lob.Getlength(v_bfile));
Dbms_Lob.Fileclose(v_bfile);
COMMIT;
END;


PL/SQL PROCEDURE successfully completed.

scott@ORA92>


SELECT * FROM imagetab


2 /


COUNT(*)
----------
1

scott@ORA92>


SELECT LENGTH (imagfile) FROM rajesh.imagetab


TRY THIS