Re: Insert BLOB into a table
- From: "Juan Carlos Reyes Pacheco" <jreyes@xxxxxxxxxxxxxxxx>
- To: <oracle-l@xxxxxxxxxxxxx>
- Date: Mon, 28 Jun 2004 17:18:13 -0400
Hi, here is an example of how I load an archive, I download using java,
because a bug, so I can't give you an example
don't forget to create directory and give privileges
FUNCTION LeeArchivo( cFile VARCHAR2, cDirectory VARCHAR2, bArchivo IN OUT
BLOB) RETURN VARCHAR2 IS
b_blob BLOB;
b_bfile BFILE;
cPath VARCHAR2(150);
cReturn VARCHAR2(2000);
BEGIN
cReturn := 'Open File, debe darse GRANT READ/WRITE ON DIRECTORY TO DAZ.';
b_bfile := BFILENAME( cDirectory , cFile );
cReturn := 'Creating temporary.';
DBMS_LOB.CREATETEMPORARY(b_blob,TRUE);
cReturn := 'Opening lobs.';
DBMS_LOB.OPEN(b_blob,DBMS_LOB.LOB_READWRITE);
DBMS_LOB.OPEN(b_bfile, DBMS_LOB.LOB_READONLY);
cReturn := 'Loading file:Dir:'||cDirectory||'-Arch:'||cFile||'-length:(
||DBMS_LOB.GETLENGTH( b_bfile )||')';
DBMS_LOB.LOADFROMFILE (b_blob,b_bfile, DBMS_LOB.GETLENGTH( b_bfile ));
cReturn := 'Close.';
DBMS_LOB.CLOSE(b_bfile);
DBMS_LOB.CLOSE(b_blob);
bArchivo :=b_blob;
cReturn := 'Free temporary.';
DBMS_LOB.FREETEMPORARY(b_blob);
RETURN 'T';
EXCEPTION WHEN OTHERS THEN
RETURN 'F-'||cReturn || SQLERRM;
END;
----------------------------------------------------------------
Please see the official ORACLE-L FAQ: http://www.orafaq.com
----------------------------------------------------------------
To unsubscribe send email to: oracle-l-request@xxxxxxxxxxxxx
put 'unsubscribe' in the subject line.
--
Archives are at http://www.freelists.org/archives/oracle-l/
FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html
-----------------------------------------------------------------
- References:
- Insert BLOB into a table
- From: Hamid Alavi
Other related posts:
- » Insert BLOB into a table
- » Re: Insert BLOB into a table
- Insert BLOB into a table
- From: Hamid Alavi