Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Insert BLOB - Best practice
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.orgReceived on Fri Nov 03 2006 - 10:29:15 CST
![]() |
![]() |