Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

ORACLE 10G - Update blob field with a jpeg

Posted on 2009-12-16
4
Medium Priority
?
1,141 Views
Last Modified: 2013-12-18
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'
0
Comment
Question by:cookiejar
3 Comments
 
LVL 2

Accepted Solution

by:
danrudolph earned 2000 total points
ID: 26068541
if your table were as follows

create table graphics_table (
  bfile_id number,
  bfile_desc varchar2(30),
  bfile_loc bfile,
  bfile_type varchar2(4))
  TABLESPACE appl_data
  storage (initial 1m next 1m pctincrease 0)
 /

INSERT INTO graphics_table
VALUES(4,'April Book of Days Woodcut',bfilename('GIF_FILES','APRIL.JPG'),'JPEG');
commit;

Hope this helps

DanRudolph
0
 

Author Comment

by:cookiejar
ID: 26068571
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?
0
 
LVL 14

Expert Comment

by:shru_0409
ID: 26069185
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
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that useā€¦
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
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.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
Suggested Courses

577 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