how can i read blob data from database into my directory (merged by CM) [message #443083] |
Fri, 12 February 2010 08:40 |
gajanan_lad
Messages: 1 Registered: February 2010 Location: Pune
|
Junior Member |
|
|
I can store my video in to my database.
but i cannot read such file.....using this procedure
ORA-29285: file write error
CREATE OR REPLACE PROCEDURE Extract_bfile
(p_id IN NUMBER)
IS
vblob BFILE;
vstart NUMBER := 1;
bytelen NUMBER := 32000;
len NUMBER;
my_vr RAW(32767);
x NUMBER;
l_output utl_file.file_type;
BEGIN
-- define output directory
l_output := utl_file.Fopen('LOG_DIR','fil1.flv','wb',32760);
vstart := 1;
bytelen := 32000;
-- get length of blob
SELECT dbms_lob.Getlength(vdata)
INTO len
FROM flvtemp
WHERE ID = p_id;
-- save blob length
x := len;
-- select blob into variable
SELECT vdata
INTO vblob
FROM flvtemp
WHERE ID = p_id;
-- if small enough for a single write
IF len < 32760 THEN
utl_raw.Cast_to_raw(l_output,vblob);
utl_file.Fflush(l_output);
ELSE -- write in pieces
vstart := 1;
WHILE vstart < len
AND bytelen > 0 LOOP
dbms_lob.Read(vblob,bytelen,vstart,my_vr);
utl_file.Put_raw(l_output,my_vr);
utl_file.Fflush(l_output);
-- set the start position for the next cut
vstart := vstart + bytelen;
-- set the end position if less than 32000 bytes
x := x - bytelen;
IF x < 32000 THEN
bytelen := x;
END IF;
utl_file.Fclose(l_output);
END LOOP;
END IF;
END;
formatted by BlackSwan
[Updated on: Fri, 12 February 2010 08:55] by Moderator Report message to a moderator
|
|
|
|
|
|
|