How to convert a CLOB to BLOB

Hi,
Can any one tell me how to convert a CLOB into BLOB? In Oracle 10g there is a function which is converttoblob(). But in Oracle 9i there is no function as such. If i am using Hextoraw() function still then its giving some pointer error. please let me know the solution.

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;

Similar Messages

  • How to convert  from  varchar to blob ?

    How to convert from varchar to blob ?
    thanks

    Here is a small PL/SQL block that we have used to convert varchar2 to blob.
    declare
    cursor get_blob is
    select blob_statement
    from report
    where report_id = 205
    FOR UPDATE OF blob_statement;
    v_loc blob;
    v_raw_buffer raw(32767);
    v_amount binary_integer := 32767;
    v_offset binary_integer := 1;
    v_buffer VARCHAR2(32767);
    begin
    open get_blob;
    fetch get_blob into v_loc;
    close get_blob;
    v_buffer := 'Sample text';
    v_raw_buffer := utl_raw.cast_to_raw(v_buffer);
    v_amount := utl_raw.length(v_raw_buffer);
    dbms_lob.write(v_loc, v_amount, v_offset, v_raw_buffer);
    commit;
    end;

  • How to Convert the content in BLOB field into a PDF file...

    Hi,
    I am having PDF files stored in BLOB column of a table in Oracle Database (11G R2).
    I want to retrieve the files back and store them in hard disk. I am successful in storing the content as a file with '.doc' but if I store the file as '.pdf', adobe fails to open the file with error
    Adobe Reader could not open file 'xxx.pdf' because it is either not a supported file type or because the file has been damaged (for example it was sent as an email attachment and wasn't correctly decoded)
    I am using following example code to achieve my goal...
    Declare
    b blob;
    c clob;
    buffer VARCHAR2(32767);
    buffer_size CONSTANT BINARY_INTEGER := 32767;
    amount BINARY_INTEGER;
    offset NUMBER(38);
    file_handle UTL_FILE.FILE_TYPE;
    begin
    select blob_data into b from blobdata where id=1;
    c := blob2clob(b);
    file_handle := UTL_FILE.FOPEN('BLOB2FILE','my_file.pdf','w',buffer_size);
         amount := buffer_size;
         offset := 1;
         WHILE amount >= buffer_size
         LOOP
              DBMS_LOB.READ(c,amount,offset,buffer);
              -- buffer:=replace(buffer,chr(13),'');
              offset := offset + amount;
              UTL_FILE.PUT(file_handle,buffer);
              UTL_FILE.FFLUSH(file_handle);
         END LOOP;
         UTL_FILE.FCLOSE(file_handle);
    end;
    create or replace FUNCTION BLOB2CLOB ( p_blob IN BLOB ) RETURN CLOB
    -- typecasts BLOB to CLOB (binary conversion)
    IS
    || Purpose : To Convert a BLOB File to CLOB File
    || INPUT : BLOB File
    || OUTPUT : CLOB File
    || History: MB V5.0 24.09.2007 RCMS00318572 Initial version
    ln_file_check NUMBER;
    ln_file_size NUMBER;
    v_text_file CLOB;
    v_binary_file BLOB;
    v_dest_offset INTEGER := 1;
    v_src_offset INTEGER := 1;
    v_warning INTEGER;
    lv_data CLOB;
    ln_length NUMBER;
    csid VARCHAR2(100) := DBMS_LOB.DEFAULT_CSID;
    V_LANG_CONTEXT NUMBER := DBMS_LOB.DEFAULT_LANG_CTX;
    BEGIN
    DBMS_LOB.createtemporary (v_text_file, TRUE);
    SELECT dbms_lob.getlength(p_blob) INTO ln_file_size FROM DUAL;
    DBMS_LOB.converttoclob (v_text_file, p_blob, ln_file_size, v_dest_offset, v_src_offset, 0, v_lang_context, v_warning);
    SELECT dbms_lob.getlength(v_text_file) INTO ln_length FROM DUAL;
    RETURN v_text_file;
    END;

    user755667 wrote:
    Hi,
    I am having PDF files stored in BLOB column of a table in Oracle Database (11G R2).
    I want to retrieve the files back and store them in hard disk. I am successful in storing the content as a file with '.doc' but if I store the file as '.pdf', adobe fails to open the file with error
    Adobe Reader could not open file 'xxx.pdf' because it is either not a supported file type or because the file has been damaged (for example it was sent as an email attachment and wasn't correctly decoded)
    I am using following example code to achieve my goal...
    Declare
    b blob;
    c clob;
    buffer VARCHAR2(32767);
    buffer_size CONSTANT BINARY_INTEGER := 32767;
    amount BINARY_INTEGER;
    offset NUMBER(38);
    file_handle UTL_FILE.FILE_TYPE;
    begin
    select blob_data into b from blobdata where id=1;
    c := blob2clob(b);
    file_handle := UTL_FILE.FOPEN('BLOB2FILE','my_file.pdf','w',buffer_size);
         amount := buffer_size;
         offset := 1;
         WHILE amount >= buffer_size
         LOOP
              DBMS_LOB.READ(c,amount,offset,buffer);
              -- buffer:=replace(buffer,chr(13),'');
              offset := offset + amount;
              UTL_FILE.PUT(file_handle,buffer);
              UTL_FILE.FFLUSH(file_handle);
         END LOOP;
         UTL_FILE.FCLOSE(file_handle);
    end;
    create or replace FUNCTION BLOB2CLOB ( p_blob IN BLOB ) RETURN CLOB
    -- typecasts BLOB to CLOB (binary conversion)
    IS
    || Purpose : To Convert a BLOB File to CLOB File
    || INPUT : BLOB File
    || OUTPUT : CLOB File
    || History: MB V5.0 24.09.2007 RCMS00318572 Initial version
    ln_file_check NUMBER;
    ln_file_size NUMBER;
    v_text_file CLOB;
    v_binary_file BLOB;
    v_dest_offset INTEGER := 1;
    v_src_offset INTEGER := 1;
    v_warning INTEGER;
    lv_data CLOB;
    ln_length NUMBER;
    csid VARCHAR2(100) := DBMS_LOB.DEFAULT_CSID;
    V_LANG_CONTEXT NUMBER := DBMS_LOB.DEFAULT_LANG_CTX;
    BEGIN
    DBMS_LOB.createtemporary (v_text_file, TRUE);
    SELECT dbms_lob.getlength(p_blob) INTO ln_file_size FROM DUAL;
    DBMS_LOB.converttoclob (v_text_file, p_blob, ln_file_size, v_dest_offset, v_src_offset, 0, v_lang_context, v_warning);
    SELECT dbms_lob.getlength(v_text_file) INTO ln_length FROM DUAL;
    RETURN v_text_file;
    END;I skimmed this and stopped reading when i saw the BLOB to CLOB function.
    You can't convert binary data into character based data.
    So very likely this is your problem.

  • 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 CLOB to UTF8

    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,
    NaG

    Joan,
    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

  • CLOB to BLOB transfer

    Hi Gurus,
    Oracle version is 11g on Windows.
    I have two identical tables with one column named images is CLOB datatype in one table and BLOB datatype in another table.
    I need to write a stored procedure to transfer all data from the first table to the second table including the CLOB column data to the BLOB column.
    Thanks
    Amitava.

    How to convert a CLOB to BLOB

  • 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

  • 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 convert BLOB data into string format.

    Hi,
    I have problem while converting blob data into string format.
    for example,
    Select dbms_lob.substr(c.shape.Get_wkb(),4000,1) from geotable c
    will get me the first 4000 byte of BLOB .
    When i using SQL as i did above,the max length is 4000, but i can get 32K using plsql as below:
    declare
    my_var CLOB;
    BEGIN
    for x in (Select X from T)
    loop
    my_var:=dbms_lob.substr(x.X,32767,1)
    end loop
    return my_var;
    I comfortably convert 32k BLOB field to string.
    My problem is how to convert blob to varchar having size more than 32K.
    Please help me to resolve this,
    Thanx in advance for the support,
    Nilesh

    Nilesh,
    . . . .The result of get_wkb() will not be human readable (all values are encoded into some binary format).
    SELECT utl_raw.cast_to_varchar2(tbl.geometry.get_wkt()) from FeatureTable tbl;
    -- resulting string:
        ☺AW(⌂özßHAA
    Å\(÷. . . .You may also want to have a look at { dbms_lob | http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_lob.htm#i1015792 } "The DBMS_LOB package provides subprograms to operate on BLOBs, CLOBs, NCLOBs, BFILEs, and temporary LOBs."
    Regards,
    Noel

  • 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.
    Daniel

    Hello 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

  • Converting CHAR or CLOB to BLOB in Oracle9i

    Hi!
    I want to convert CHAR or CLOB to BLOB.
    I am working with Oracle9i Database.
    Oracle9i Supplied PL/SQL Package Release 2 (9.2) does'nt support DBMS_LOB.CONVERTTOBLOB procedure.
    How I can convert CHAR or CLOB to BLOB in Oracle9i?
    Valery

    Hi Valery,
    For conversion to blob, just try the utl_raw package.
    I use utl_raw.cast_to_raw quite often.
    Or have a look at:
    http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:437819871174
    Good luck,
    Jan-Marcel

  • How to convert BLOB into a String

    Hi,
    I got a blob column from the database.
    It contains one XML File.
    How to convert it into String.
    I need the code for how to convert the blob into String
    Thanks in Advance.

    A blob would be a byte-array, which you can use in the String(byte[]) constructor

  • Convert clob to blob

    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 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,
    Manoj

    Hello,
    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

  • 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 source

    The same question was asked just two days ago No Data Found: ORA-22992
    Nikolai Rochnik

Maybe you are looking for