dbTalk Databases Forums  

Insert BLOB - Best practice

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss Insert BLOB - Best practice in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
jaft
 
Posts: n/a

Default Insert BLOB - Best practice - 11-02-2006 , 11:58 PM






Hi

I have a plsql stored procedure that takes a blob as input parameter.
I have to insert this parameter into a table.
What's the best practice to insert a new blob value into a blob column?
I ask that, because I have read that before inserting a blob value into
a table, I must first execute an insert statement with empty_blob() and
than use the dbms_lob.write instead of inserting directly the blob
value.

create table myTable (id NUMBER, ablob BLOB)
/

create or replace procedure insert_blob (myBlob BLOB) as

lob_loc myTable.ABLOB%TYPE;

begin

insert into myTable values (1, myBlob);

--OR--

insert into myTable values (1, empty_blob()) return ablob into
lob_loc;

dbms_lob.write (lob_loc, dbms_lob.getlength(myBlob), 1,
myBlob);

commit;

end;


Reply With Quote
  #2  
Old   
DA Morgan
 
Posts: n/a

Default Re: Insert BLOB - Best practice - 11-03-2006 , 10:29 AM






jaft wrote:
Quote:
Hi

I have a plsql stored procedure that takes a blob as input parameter.
I have to insert this parameter into a table.
What's the best practice to insert a new blob value into a blob column?
I ask that, because I have read that before inserting a blob value into
a table, I must first execute an insert statement with empty_blob() and
than use the dbms_lob.write instead of inserting directly the blob
value.

create table myTable (id NUMBER, ablob BLOB)
/

create or replace procedure insert_blob (myBlob BLOB) as

lob_loc myTable.ABLOB%TYPE;

begin

insert into myTable values (1, myBlob);

--OR--

insert into myTable values (1, empty_blob()) return ablob into
lob_loc;

dbms_lob.write (lob_loc, dbms_lob.getlength(myBlob), 1,
myBlob);

commit;

end;

There is a working demo in Morgan's Library at www.psoug.org
under Blob Load Demo.
--
Daniel A. Morgan
University of Washington
damorgan@x.washington.edu
(replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.