How to show a word document stored in a BLOB column? (through forms 6i) [message #426801] |
Mon, 19 October 2009 14:48 |
alexduailibi
Messages: 5 Registered: October 2009 Location: Brasil
|
Junior Member |
|
|
Hi guys.
I'm trying to show the content of a MS Word document through forms 6i. This document was stored as byte-for-byte by an application developed in .Net to an BLOB column (oracle table). Anybody could help me in how to show this document using Internal Persistend LOBs and through forms 6i?
I've been searching for it a lot of time without success...
Thank you in advance.
Alex.
|
|
|
|
|
Re: How to show a word document stored in a BLOB column? (through forms 6i) [message #427108 is a reply to message #426991] |
Wed, 21 October 2009 03:22 |
lancer26
Messages: 52 Registered: May 2006 Location: Pakistan
|
Member |
|
|
use this as sample
DECLARE
i1 BLOB;
len NUMBER;
my_vr RAW(10000);
i2 NUMBER;
i3 NUMBER := 10000;
BEGIN
-- get the blob locator
SELECT c2
INTO i1
FROM lob_tab
WHERE c1 = 2;
-- find the length of the blob column
len := dbms_lob.getlength(i1);
dbms_output.put_line('Column Length: ' || TO_CHAR(len));
-- Read 10000 bytes at a time
i2 := 1;
IF len < 10000 THEN
-- If the col length is < 10000
dbms_lob.read(i1,len,i2,my_vr);
outputstring('p:\bfiles\ravi.bmp',
rawtohex(my_vr),'wb',2*len);
-- You have to convert the data to rawtohex format.
-- Directly sending the buffer
-- data will not work
-- That is the reason why we are sending the length as
-- the double the size of the data read
dbms_output.put_line('Read ' || to_char(len) || 'Bytes');
ELSE
-- If the col length is > 10000
dbms_lob.read(i1,i3,i2,my_vr);
outputstring('p:\bfiles\ravi.bmp',
rawtohex(my_vr),'wb',2*i3);
dbms_output.put_line('Read ' || TO_CHAR(i3) || ' Bytes ');
END IF;
i2 := i2 + 10000;
WHILE (i2 < len )
LOOP
-- loop till entire data is fetched
dbms_lob.read(i1,i3,i2,my_vr);
dbms_output.put_line('Read ' || TO_CHAR(i3+i2-1) ||
' Bytes ');
outputstring('p:\bfiles\ravi.doc',
rawtohex(my_vr),'ab',2*i3);
i2 := i2 + 10000 ;
END LOOP;
END;
and try this...
DECLARE
xmlstr BLOB;
warn VARCHAR2(400);
v_file Utl_File.file_type;
line_buf RAW(32767);
maxbufsize BINARY_INTEGER := 32767;
amount BINARY_INTEGER;
offset varchar2(40);
dir varchar2(50) := 'XMLP_DIR';
filename varchar2(50) := 'OUTPUTFILE.rtf';
bsize NUMBER;
BEGIN
v_file := utl_file.fopen(dir,filename,'w',maxbufsize);
SELECT column1 INTO xmlstr FROM my_table WHERE name = 'RTFDOCUMENT';
bsize := dbms_lob.getLength(xmlstr);
dbms_output.put_line(bsize);
amount := maxbufsize;
offset := 1;
WHILE (offset<bsize) LOOP
DBMS_LOB.read(xmlstr,amount,offset,line_buf);
utl_file.put_raw(v_file,line_buf, TRUE);
offset := offset+amount;
Dbms_Output.put_line(offset);
END LOOP;
utl_file.fclose(v_file);
END;
|
|
|