How to convert clob to blob
hi
tell me some thong how we can convert clob to blob
You can use my procedure
create or replace procedure CLOB2BLOB (p_clob in out nocopy clob, p_blob in out nocopy blob) is
-- transforming CLOB â BLOB
l_off number default 1;
l_amt number default 4096;
l_offWrite number default 1;
l_amtWrite number;
l_str varchar2(4096 char);
begin
begin
loop
dbms_lob.read ( p_clob, l_amt, l_off, l_str );
l_amtWrite := utl_raw.length ( utl_raw.cast_to_raw( l_str) );
dbms_lob.write( p_blob, l_amtWrite, l_offWrite,
utl_raw.cast_to_raw( l_str ) );
l_offWrite := l_offWrite + l_amtWrite;
l_off := l_off + l_amt;
l_amt := 4096;
end loop;
exception
when no_data_found then
NULL;
end;
end;
Best regards, Victor
Similar Messages
-
How to convert CLOB to BLOB with SQL Developer migration wizard?
Hi,
According to our requirement, we need to only migrate data from SQL Server 2008 to Oracle 11. I use the SQL Developer 3.0.04 migration wizard to do it.
I do migration from SQL Server (database name: SCDS41P2) to Oracle (User name: HCDS41P2).
My migration steps are as below: (I need to modify the target schema, so I add the steps 2) and step 3) )
1) Do migration by SQL Developer migration wizard;
2) Remove the Converted Database Objects node from migration project;
3) Re-do convert by SQL Developer migration wizard (contains changing the target schema);
When do step 1), the DBO_SCDS41P2 user is created automatically. CLOBTOBLOB_SQLDEVELOPER procedure is also created in this user.
I continued to run step 2) and step 3) with online mode. And find the table data which contains BLOB column can be moved into the target table. But from the Logging Page, I can't see the other detailed error info, so that I can't check which tables don't move data successfully.
Could you please tell me where the detail log file (e.g. contains every table's migration status) is if I use the online mode?
Additional, If I use offline mode to do step 3), I found the CLOB data can't be converted into BLOB automatically. Because in the load script (that is oracle_ctl.bat), only copy the source data to the CLOB column. After copy, it don't deal with the converting from CLOB to BLOB.
So could you please tell me how to convert CLOB to BLOB with offline mode?
Thanks so much.Hi,
For your first question about logging - after the migration there will be an entry in the right hand panel for the migration project. If you open this there are various fields that give information about the status of each part of the migration. Does this give you the information you need ?
For the second problem about offline moving blob data have a look at the SQL*Developer documentation -
Oracle® SQL Developer User’s Guide Release 3.0
in the section -
2.2.8.1.4 Populating the Destination Database Using the Data Files
which describes the problem and how to get round it.
Regards,
Mike
Edited by: mkirtley on Aug 12, 2011 10:49 AM -
How to convert clobs to blobs?
What is the easiest way to go if I want to copy the content of a CLOB to a BLOB(Other than reading the contents of the CLOB out into a buffer and then apply UTL_RAW.CAST_TO_RAW)? How about from blobs to clobs?
nullHi,
create table myblob(x blob);
create table myblob1(x clob);
create or replace procedure blob_to_clob as
b_lob blob;
buffer VARCHAR2(32000);
g_length number;
begin
select x into b_lob from myblob;
g_length := dbms_lob.getlength(b_lob);
dbms_lob.read(b_lob,g_length,1,buffer);
insert into myblob1 values(buffer);
commit;
end;
null -
How to use clob or blob data type in OWB
how to use clob or blob data type in OWB?
if OWB not surport these data type,how can i extract the large data type from data sourceThe same question was asked just two days ago No Data Found: ORA-22992
Nikolai Rochnik -
I am trying to convert clob into blob through following code.
CREATE OR REPLACE FUNCTION clob_to_blob (clob_in IN CLOB)
RETURN BLOB
AS
v_blob BLOB;
v_varchar RAW(32767);
v_start BINARY_INTEGER := 1;
v_buffer BINARY_INTEGER := 32767;
BEGIN
FOR i IN 1..CEIL(DBMS_LOB.GETLENGTH(clob_in) / v_buffer)
LOOP
v_varchar := UTL_RAW.CAST_TO_RAW(DBMS_LOB.SUBSTR(clob_in, v_buffer, v_start)) ;
DBMS_OUTPUT.PUT_LINE('DATA :' ||DBMS_LOB.SUBSTR(clob_in, v_buffer, v_start));
DBMS_OUTPUT.PUT_LINE(' V_VARCHAR :'|| v_VARCHAR);
DBMS_OUTPUT.PUT_LINE(' V_VARCHAR LENGTH :'|| LENGTH(v_VARCHAR));
DBMS_LOB.WRITEAPPEND(v_blob, LENGTH(v_VARCHAR), v_varchar);
DBMS_OUTPUT.PUT_LINE('after append');
v_start := v_start + v_buffer;
END LOOP;
RETURN v_blob;
END clob_to_blob;
calling code:
declare
var clob;
begin
var:='3433534534de';
testblob(var);
end;
It gives me following error:
declare
ERROR at line 1:
ORA-21560: argument 2 is null, invalid, or out of range
i don't know whats the prob?
thanxdbms_lob.writeappend expects a real lob locator, which you can only get by selecting from a lob column.
create table blobtab (b blob);
insert into blobtab values (empty_blob());
CREATE OR REPLACE FUNCTION clob_to_blob (clob_in IN CLOB)
RETURN BLOB
AS
v_blob blob;
v_varchar RAW(32767);
v_start BINARY_INTEGER := 1;
v_buffer BINARY_INTEGER := 32767;
BEGIN
select b into v_blob from blobtab;
FOR i IN 1..CEIL(DBMS_LOB.GETLENGTH(clob_in) / v_buffer)
LOOP
v_varchar := UTL_RAW.CAST_TO_RAW(DBMS_LOB.SUBSTR(clob_in, v_buffer, v_start)) ;
DBMS_OUTPUT.PUT_LINE(' DATA :' || DBMS_LOB.SUBSTR(clob_in, v_buffer, v_start));
DBMS_OUTPUT.PUT_LINE(' V_VARCHAR :' || v_VARCHAR);
DBMS_OUTPUT.PUT_LINE(' V_VARCHAR LENGTH :' || utl_raw.LENGTH(v_VARCHAR));
DBMS_LOB.WRITEAPPEND(v_blob, utl_raw.LENGTH(v_VARCHAR), v_varchar);
DBMS_OUTPUT.PUT_LINE('after append');
v_start := v_start + v_buffer;
END LOOP;
RETURN v_blob;
END clob_to_blob;
declare
blobvar blob;
begin
blobvar := clob_to_blob(dbms_xmlgen.getXML('select 1 from dual'));
end;
/ -
Converting CLOB to BLOB at once
Hello all!
I have to convert CLOB to BLOB in my application. My CLOB contains XML document built with dbms_xmldom, an I need to put it into column of type BLOB. Knowing several ways to do it, I'm searching for the best one. So I considered the folowing:
- Size of XML data can be more then 4000 bytes.
- I can convert it "piecewise", copying through varchar2 and raw buffers by chunks. But this is not efficient for me.
- I can write CLOB to file, then read it into BLOB. But it is not efficient too.
- I can not change column type to CLOB since it may contain other BLOB data, not XML.
Actually, I need a way to "cast" CLOB data as binary data when inserting into table. I believe Oracle must have it, but where?
I'll be very grateful for help from anyone.
P.S. Using Oracle 9.2You could use UTL_RAW.CAST_TO_RAWhttp://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96612/u_raw2.htm#998330
The XML data can be 32k (the varchar2 limit in PLSQL is 32k, not 4000 bytes)
If your documents exceeds 32k you need process chunks -
How to convert CLOB data (now it is in html format) to Normal text format
Hi,
Can anybody let me know the solution for how to convert CLOB data into normal Text.In my case the table column having CLOB datatype and the data is in html format.when i run the report the column is displaying html tags .Now i need to convert that html tags into normal text.
Pl. let me know if any one know the solution.
Regards,
Thulasi.KLONG has been depricated since 8i so I don't believe there is a general solution to go backwards short of reloading the data.
Justin -
LOB : how convert CLOB into BLOB
This code doesn't work : ORA-06502: PL/SQL: numeric or value error: hex to raw conversion error.
declare
vCLOB CLOB := empty_clob();
vBLOB BLOB := empty_blob();
begin
dbms_lob.createTemporary(vCLOB,TRUE);
dbms_lob.open(vCLOB, DBMS_LOB.LOB_READWRITE);
-- Put data into CLOB
l_length := dbms_lob.getlength(vCLOB);
dbms_lob.read(vCLOB,l_length,1,buffer);
dbms_lob.createTemporary(vBLOB,TRUE);
dbms_lob.open(vBLOB, DBMS_LOB.LOB_READWRITE);
dbms_lob.write(vBLOB,l_length,1,buffer);
dbms_lob.close(vBLOB);
dbms_lob.freeTemporary(vBLOB);
dbms_lob.close(vCLOB);
dbms_lob.freeTemporary(vCLOB);
Thanks.You can use my procedure
create or replace procedure CLOB2BLOB (p_clob in out nocopy clob, p_blob in out nocopy blob) is
-- transforming CLOB â BLOB
l_off number default 1;
l_amt number default 4096;
l_offWrite number default 1;
l_amtWrite number;
l_str varchar2(4096 char);
begin
begin
loop
dbms_lob.read ( p_clob, l_amt, l_off, l_str );
l_amtWrite := utl_raw.length ( utl_raw.cast_to_raw( l_str) );
dbms_lob.write( p_blob, l_amtWrite, l_offWrite,
utl_raw.cast_to_raw( l_str ) );
l_offWrite := l_offWrite + l_amtWrite;
l_off := l_off + l_amt;
l_amt := 4096;
end loop;
exception
when no_data_found then
NULL;
end;
end;
Best regards, Victor -
How to call CLOB to BLOB conversion function within stored procedure?
I have a tiny APEX application from which I need to be able to print. I’ve used these two resources: (Is there an inexpensive APEX report printer for invoices/checks/statements? and http://download.oracle.com/docs/cd/E14373_01/appdev.32/e13363/up_dn_files.htm#CJAHDJDA)
I guess that in order to be able to download the RTF document stored in CLOB, I need to convert it into BLOB. I’ve found this function for this purpose on Oracle forums:
CREATE OR REPLACE FUNCTION c2b( c IN CLOB ) RETURN BLOB
-- typecasts CLOB to BLOB (binary conversion)
IS
pos PLS_INTEGER := 1;
buffer RAW( 32767 );
res BLOB;
lob_len PLS_INTEGER := DBMS_LOB.getLength( c );
BEGIN
DBMS_LOB.createTemporary( res, TRUE );
DBMS_LOB.OPEN( res, DBMS_LOB.LOB_ReadWrite );
LOOP
buffer := UTL_RAW.cast_to_raw( DBMS_LOB.SUBSTR( c, 16000, pos ) );
IF UTL_RAW.LENGTH( buffer ) > 0
THEN
DBMS_LOB.writeAppend( res, UTL_RAW.LENGTH( buffer ), buffer );
END IF;
pos := pos + 16000;
EXIT WHEN pos > lob_len;
END LOOP;
RETURN res; -- res is OPEN here
END c2b;And I am trying to use it in the modified download procedure that I also have found on Oracle forums:
CREATE OR REPLACE PROCEDURE DOWNLOAD_WO(v_id IN NUMBER)
AS
v_mime VARCHAR2(48);
v_length NUMBER;
v_file_name VARCHAR2(2000):= 'WO_Download.rtf';
lob_loc CLOB;
v_blob BLOB;
v_company jobs_vw.company%TYPE;
v_project jobs_vw.project%TYPE;
v_description jobs_vw.description%TYPE;
v_date_ jobs_vw.date_%TYPE;
v_job_no jobs_vw.job_no%TYPE;
v_apqwo jobs_vw.apqwo%TYPE;
-- v_mime VARCHAR2(48) := 'application/msword';
BEGIN
SELECT mime_type, report, DBMS_LOB.GETLENGTH(report)
INTO v_mime,lob_loc,v_length
FROM report_layouts
WHERE rl_id = 22332925279634283;
-- JOB_VW record:
SELECT job_no
,date_
,description
,apqwo
,project
,company
INTO v_job_no
,v_date_
,v_description
,v_apqwo
,v_project
,v_company
FROM jobs_vw
WHERE id = 214;
-- Replace holders with actual values:
lob_loc := REPLACE(lob_loc, '#COMPANY#', v_company);
lob_loc := REPLACE(lob_loc, '#PROJECT#', v_project);
lob_loc := REPLACE(lob_loc, '#DESCRIPTION#', v_description);
lob_loc := REPLACE(lob_loc, '#DATE_#', TO_CHAR(v_date_, 'DD/MM/YYYY'));
lob_loc := REPLACE(lob_loc, '#JOB_NO#', v_job_no);
lob_loc := REPLACE(lob_loc, '#APQWO#', v_apqwo);
-- set up HTTP header
-- use an NVL around the mime type and
-- if it is a null set it to application/octect
-- application/octect may launch a download window from windows
owa_util.mime_header( nvl(v_mime,'application/octet'), FALSE );
-- set the size so the browser knows how much to download
htp.p('Content-length: ' || v_length);
-- the filename will be used by the browser if the users does a save as
htp.p('Content-Disposition: attachment; filename="'||replace(replace(substr(v_file_name,instr(v_file_name,'/')+1),chr(10),null),chr(13),null)|| '"');
-- close the headers
owa_util.http_header_close;
-- download the BLOB
-- wpg_docload.download_file( Lob_loc );
v_blob := c2b(lob_loc);
wpg_docload.download_file( v_blob );
end DOWNLOAD_WO;
/Unfortunately when I try to compile the download_wo stored procedure I am getting this error:
Error at line 64: PL/SQL: Statement ignoredThe 64th line is:
v_blob := c2b(lob_loc);How should I correctly call c2b within download_wo? Any advice is greatly appreciated.
Thank you for your time.
DanielHello there,
Well, its invalid :(
Object C2B is Invalid. I didn't know since when I run the create ... function, I only get this feedback:
Statement processed.
0.19 secondsI am investigating.
Daniel -
Anyone know an easy way to convert clob data to blob data?
We upgraded a client to 8.1.7.2 and now we can no longer store MS-Word templates to the RDBMS.
I deduce this is because MS-Word templates are binary files.
Earlier versions of 8.1.7 and 8.1.6 allowed us to do this. However, this is no longer the case.
Some of my clob rows are over 6 meg.
I have written some PL/SQL code to basically retrieve the clob data in cursor, loops through the clob in 32767 blocks,
performing dbms_lob.substr, converts that data to hex(major pain), & then write the blocks using dbmbs_lob.write.
I keep getting the proverbial "ORA-06502: PL/SQL: numeric or value error: invalid LOB locator specified: ORA-22275".
Does anyone see flaws in my approach and might have an easier solution?
Thanks!Here's my code:
REATE OR REPLACE
PROCEDURE p_load_clob_to_blob IS
* Name: p_load_clob_to_blob
* Parameters: None
* Purpose: This procedure loads the narr_blob column in the narr table_text with clob data from the
* narr column.
* Notes: This procedure assumes that narr table has been altered with narr_blob column added.
* See the SQL below:
* alter table narr_text add (narr_blob blob);
* Once this procedure executes, the table must altered to drop the narr_text clob column,
* recreate the narr_text as blob, & then repopulate narr_text. See the SQL below:
* alter table narr_text drop column narr;
* alter table narr_text add (narr blob);
* update narr_text set narr = narr_blob;
* commit;
* Called By: Sys Admin
* CHANGE LOG
* Changed By Date Change Description
* EAO 01/16/02 Created.
rec_read INTEGER;
rec_update INTEGER;
write_cnt INTEGER;
write_amount BINARY_INTEGER;
write_offset INTEGER;
write_loop INTEGER;
total_length NUMBER;
total_written NUMBER;
buffer VARCHAR2(32767);
bbuffer RAW(32767);
temp_narr_id NUMBER;
max_loop INTEGER;
cx CLOB;
bx BLOB;
bx2 BLOB;
cur_evt varchar2(50); -- current event
v_err_descr varchar2(256);
i INTEGER;
hex varchar(32767);
CURSOR c_load_narr_clob IS
SELECT narr, narr_id
FROM narr_text
where narr_id = 6366;
BEGIN
insert_event_log('', 'p_load_clob_to_blob', '', '', '', 'p_load_clob_to_blob started', '');
rec_read := 0;
rec_update := 0;
---Fill file
insert_event_log('', 'p_load_clob_to_blob ','c_load_narr_clob ', '', 'S', 'c_narr_clob started', '');
FOR csr IN c_load_narr_clob LOOP
cur_evt := 'Select narr from narr table: ';
rec_read := rec_read + 1;
write_loop := 1;
write_cnt := 0;
write_offset := 1;
total_written := 0;
cx := csr.narr;
bx := empty_blob();
total_length := DBMS_LOB.GETLENGTH(cx);
max_loop := (total_length / 32767) + 1;
if (total_length <= 32767) THEN
write_amount := total_length;
ELSE
write_amount := 32767;
END IF;
dbms_output.put_line('Length=' || to_char(total_length) || ' Max loop=' || to_char(max_loop) || ' Write Amount=' || to_char(write_amount));
temp_narr_id := csr.narr_id;
while write_cnt < max_loop
loop
--FOR write_loop in 1..max_loop LOOP
delete temp_blob;
delete temp_raw;
commit;
cur_evt := 'Dbms_lob.substr: ';
dbms_output.put_line(cur_evt);
buffer := DBMS_LOB.SUBSTR(cx, write_amount, write_offset);
dbms_output.put_line('Write Amount='|| to_char(write_amount) || ' Write Offset=' || to_char(write_offset) );
cur_evt := 'Hex to Raw Assigment: ';
dbms_output.put_line(cur_evt);
bbuffer := null;
for i in 1..write_amount loop
hex := numtohex(ascii(substrb(buffer,i,1)));
bbuffer := bbuffer || hextoraw(hex);
end loop;
cur_evt := 'Insert temp_raw: ';
dbms_output.put_line(cur_evt);
insert into temp_raw(rx)
values (bbuffer);
commit;
cur_evt := 'Insert temp_blob: ';
dbms_output.put_line(cur_evt);
execute immediate 'insert into temp_blob(bx)
select TO_LOB(rx) from temp_raw';
commit;
cur_evt := 'Select bx2: ';
dbms_output.put_line(cur_evt);
bx2 := empty_blob();
select bx into bx2 from temp_blob;
cur_evt := 'Dbms_lob.append: ';
dbms_output.put_line(cur_evt);
dbms_lob.append(bx, bx2);
dbms_output.put_line('Write Amount='|| to_char(write_amount) || ' Write Offset=' || to_char(write_offset) );
write_offset := write_offset + write_amount;
total_written := total_written + write_amount;
write_cnt := write_cnt + 1;
if (write_cnt = max_loop) then
write_amount := total_length - total_written;
end if;
END LOOP;
dbms_output.put_line('Total_written = ' || to_char(total_written) );
cur_evt := 'Upd narr_blob in narr table: ';
update narr_text
set narr_blob = bx
where narr_id = temp_narr_id;
rec_update := rec_update + 1;
commit;
END LOOP;
insert_event_log('', 'p_load_clob_to_blob ','c_load_narr_clob ', '', 'C', 'c_narr_clob completed', '');
dbms_output.put_line('Records read=' || to_char(rec_read) || ' Records updated=' || to_char(rec_update) );
insert_event_log('', 'p_load_clob_to_blob', '', '', '', 'p_load_clob_to_blob ended', '');
EXCEPTION
WHEN OTHERS THEN
Rollback;
v_err_descr := 'FATAL ERROR OCCURRED -'||cur_evt||sqlerrm;
dbms_output.put_line (v_err_descr);
END;
FUNCTION numtohex(v_hex number) return varchar2
is
hex varchar2(4);
num1 number;
num2 number;
begin
num1 := trunc(v_hex/16);
num2 := v_hex-(num1*16);
if ( num1 >= 0 and num1 <= 9 ) then
hex := hex||to_char(num1);
end if;
if num1 = 10 then hex := hex||'A'; end if;
if num1 = 11 then hex := hex||'B'; end if;
if num1 = 12 then hex := hex||'C'; end if;
if num1 = 13 then hex := hex||'D'; end if;
if num1 = 14 then hex := hex||'E'; end if;
if num1 = 15 then hex := hex||'F'; end if;
if ( num2 >= 0 and num2 <= 9 ) then
hex := hex||to_char(num2);
end if;
if num2 = 10 then hex := hex||'A'; end if;
if num2 = 11 then hex := hex||'B'; end if;
if num2 = 12 then hex := hex||'C'; end if;
if num2 = 13 then hex := hex||'D'; end if;
if num2 = 14 then hex := hex||'E'; end if;
if num2 = 15 then hex := hex||'F'; end if;
return hex;
end; -
How to convert varchar to BLOB in oracle 10g?
Hi all,
I have 2 columns A and B which are of varchar2(2000) dataype.
I would like to concatinate these 2 columns and convert them into BLOB in oracle 10g.
Any help is appreciated.
Regards,
Ravidon't use BLOB to store large text, use CLOB instead
anyway:
SQL> create table test
2 (txt varchar2(10)
3 ,other varchar2(10)
4 );
Table created.
SQL>
SQL> insert into test values ('some text', 'other text');
1 row created.
SQL>
SQL> create table test2
2 (col blob)
3 /
Table created.
SQL>
SQL> insert into test2
2 select utl_raw.cast_to_raw (txt||other)
3 from test
4 /
1 row created.
SQL> select *
2 from test2
3 /
SP2-0678: Column or attribute type can not be displayed by SQL*Plus
SQL>
SQL> select utl_raw.cast_to_varchar2(col)
2 from test2
3 /
UTL_RAW.CAST_TO_VARCHAR2(COL)
some textother text
SQL>
SQL> drop table test
2 /
Table dropped.
SQL> drop table test2
2 /
Table dropped. -
How we handle CLOB and BLOB Datatypes in HANA DB
Dear HANA Gurus,
We have would like to build EDW using HANA base on our source system Oracle and it's supports CLOB and BLOB datatypes
Would you please suggest how do we handle in HANA DB.
Let not say it's oracle specific.
Regards,
ManojHello,
check SAP HANA SQL Reference Guide for list of data types:
(page 14 - Classification of Data Types)
https://service.sap.com/~sapidb/011000358700000604922011
For this purpose might be useful following data types:
Large Object (LOB) Types
LOB (large objects) data types, CLOB, NCLOB and BLOB, are used to store a large amount of data such as text documents and images. The maximum size of an LOB is 2 GB.
BLOB
The BLOB data type is used to store large binary data.
CLOB
The CLOB data type is used to store large ASCII character data.
NCLOB
The NCLOB data type is used to store a large Unicode character object.
Tomas -
Converting varchar2 to BLOB or converting CLOB to BLOB
Hi i am using a table where i have to convert a field currently existing as a varchar2 or CLOB to a BLOB field.
while doing this i also have to preserve the data currently existing in the table.
Please help.
ThanksCLOB to a BLOB CREATE OR REPLACE FUNCTION clob_to_blob (clob_in IN CLOB) RETURN BLOB AS
v_blob BLOB;
v_varchar RAW(32001);
v_varchar1 RAW(32001);
v_start INTEGER := 1;
v_buffer INTEGER := 32001;
BEGIN
DBMS_LOB.CREATETEMPORARY(v_blob, TRUE);
FOR i IN 1..CEIL(DBMS_LOB.GETLENGTH(clob_in) / v_buffer) LOOP
DBMS_LOB.READ(clob_in,v_buffer,v_start,v_varchar);
DBMS_LOB.WRITEAPPEND(v_blob, utl_raw.length(v_varchar), v_varchar);
v_start := v_start + v_buffer;
END LOOP;
RETURN v_blob;
END clob_to_blob;
/ -
Invalid data after converting clob to blob
GOAL: insert adresse or someth. into an msword file out of database
Hi,
I'm working with a 9i database and I'm trying to insert data in a clob. First I convert the blob, which is a stored xml- file in my databse, to a clob. after that i'm replacing the data I want to insert and then reconverting to blob. It goes very well, but when the data I insert contains a 'ö' or 'ä' or 'ß' the blob file i get is invalid and can't be read by msword! I opened the file with notepad and instead of 'ö' etc there is a very strange sign like a square. here is my plsql- code:
loop
test:=substr(v_clob,posi,len);
posi:=posi+32767;
if length(v_clob)-posi<32767 then
len:=length(v_clob)-posi+1;
end if;
--vartest:=utl_raw.cast_to_raw(v_clob);
DBMS_LOB.WRITE(r_blob, length(test),posi-32767, utl_raw.cast_to_raw(test));
exit when posi>length(v_clob);
end loop;
DBMS_LOB.freetemporary(v_clob);
return r_blob;
because of 9i doesn't contain the procedure dbms_lob.converttoblob i user utl_raw.cast_to_raw and split my clob in several parts with a size of 32767 characters
i also tried with utl_raw.convert with several character sets, but don't know which one to take...
nls_lang of database server is set to GERMAN_GERMANY.WE8MSWIN1252
can anyone help me please!
Message was edited by:
user472439dbms_lob.writeappend expects a real lob locator, which you can only get by selecting from a lob column.
create table blobtab (b blob);
insert into blobtab values (empty_blob());
CREATE OR REPLACE FUNCTION clob_to_blob (clob_in IN CLOB)
RETURN BLOB
AS
v_blob blob;
v_varchar RAW(32767);
v_start BINARY_INTEGER := 1;
v_buffer BINARY_INTEGER := 32767;
BEGIN
select b into v_blob from blobtab;
FOR i IN 1..CEIL(DBMS_LOB.GETLENGTH(clob_in) / v_buffer)
LOOP
v_varchar := UTL_RAW.CAST_TO_RAW(DBMS_LOB.SUBSTR(clob_in, v_buffer, v_start)) ;
DBMS_OUTPUT.PUT_LINE(' DATA :' || DBMS_LOB.SUBSTR(clob_in, v_buffer, v_start));
DBMS_OUTPUT.PUT_LINE(' V_VARCHAR :' || v_VARCHAR);
DBMS_OUTPUT.PUT_LINE(' V_VARCHAR LENGTH :' || utl_raw.LENGTH(v_VARCHAR));
DBMS_LOB.WRITEAPPEND(v_blob, utl_raw.LENGTH(v_VARCHAR), v_varchar);
DBMS_OUTPUT.PUT_LINE('after append');
v_start := v_start + v_buffer;
END LOOP;
RETURN v_blob;
END clob_to_blob;
declare
blobvar blob;
begin
blobvar := clob_to_blob(dbms_xmlgen.getXML('select 1 from dual'));
end;
/ -
Hi all,
We have batch job which actually runs on daily basis and produces XML with the Java code.And the XML generated is used for various purposes.
Recently the job was not executed successfully because of some special characters in XML which falls out of ANSI encoding stantands.
So we are in a situation to convert the CLOB datatype (input to Java code) to UTF8 encoded XML.
We are not to able to achieve this .
Right now the cloB data is converted to ASCII stream,which doesn't create a well formed XML based on UTF8 encoding standards.See below the code
clob xmlCLOB = (Clob)clobInfo.get("clobfield");
InputStream is = xmlCLOB.getAsciiStream();
Any thoughts on how to convert this CLOB to UTF8?
Regards,
NaGJoan,
I don't know if this will help with conversion of you BFILE, but at
http://www.xml.com/lpt/a/2000/04/26/encodings/xmlparser.html
and at
http://xmlsoft.org/encoding.html
there is some information on conversion to UTF8.
Hope it helps. Let us know.
Dave
Maybe you are looking for
-
A little problem getting the style tag of a html file seperate from rest
I'm making a program that will take in a URL and then search through that URL for all a, link, embed, frame, and img tags, find their sources, and download them. I also want to search through the style and find anything that uses a URL (ex. backgroun
-
Play a movie (flv) then go to the website homepage
I have an flv movie clip imported into a nice swf skin and it looks and performs wonderful. When it's done I want to immediately navigate to the home page of my site... how do I do this? If you would be so kind as to provide me with a sample script f
-
No radio in menu of iTunes 7.5?
So I have downloaded iTunes 7.5 and would like to listen to streaming radio programs. However, all the Support instructions say to just click on the radio icon that's in the left hand nav and I do not see any icon. It is just not there. Is there some
-
TS1424 error when enter password in itunes on mac
i got this error message when putting in my itunes password on my mac: "Connectionmanager::invoke::Failed to find service connection url" I reset my password, signed out and signed back in, and got the same message again. i was able to sign in to m
-
Safari won't allow me to download ICloud control panel on my IPad, so I can download my pictures FROM my PC