Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Insert BLOB - Best practice

Re: Insert BLOB - Best practice

From: DA Morgan <damorgan_at_psoug.org>
Date: Fri, 03 Nov 2006 08:29:15 -0800
Message-ID: <1162571352.473050@bubbleator.drizzle.com>


jaft wrote:
> 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_at_x.washington.edu
(replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org
Received on Fri Nov 03 2006 - 10:29:15 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US