BLOB-- CLOB-- BLOB conversion reducing length of BLOB

Hi,
I am using the following BLOB-->CLOB and CLOB-->BLOB conversion functions :
CREATE OR REPLACE FUNCTION blob_to_clob (blob_in IN BLOB)
RETURN CLOB
AS
     v_clob CLOB;
     v_varchar RAW(32001);
     v_varchar1 VARCHAR2(32001);
     v_start     INTEGER := 1;
     v_buffer INTEGER := 32001;
BEGIN
     DBMS_LOB.CREATETEMPORARY(v_clob, TRUE);
     FOR i IN 1..CEIL(DBMS_LOB.GETLENGTH(blob_in) / v_buffer)
     LOOP
     DBMS_LOB.READ(blob_in,v_buffer,v_start,v_varchar);
DBMS_LOB.WRITEAPPEND(v_clob, utl_raw.length(v_varchar), v_varchar);
     v_start := v_start + v_buffer;
     END LOOP;
RETURN v_clob;
END blob_to_clob;
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;
I am using these functions to convert image files, stored as BLOB to CLOB for intermediate storage, and then converting them back to BLOB. In this process, I see a loss of information when the image is converted from CLOB to BLOB ...which is seen by using dbms_lob.getlength() .Using the following sql query:
select dbms_lob.getlength(file_body),
dbms_lob.getlength(blob_to_clob(file_body)),
     dbms_lob.getlength(clob_to_blob(blob_to_clob(file_body)))
from my_table where image_id in (8819)
i see that returned length is usually half in the 3rd column, i.e. for dbms_lob.getlength(clob_to_blob(blob_to_clob(file_body))). There is no change in length for 1st and 2nd columns. Could you please let me know why length is getting lost in the CLOB to BLOB conversion ? Thanks.

Thanks for replying.
This is required because we have to store images in ldt files using FNDLOAD, whiich only supports CLOB, not BLOB. I understand that images stored in binary formats should be stored in BLOB only, but I am exploring the possibility of converting BLOB format to CLOB and then back to BLOB without loss of information. Any pointers in this regard are appreciated. Thanks !

Similar Messages

  • Blob to Clob XML conversion problem

    Hello,
    I have a table with a blob column that contains different types of documents (.doc, .pdf, .gif, .xml, etc). The xml documents use UTF-8 encoding and contain some of the multi-byte characters. I'm trying to extract and convert the xml blob content into a clob variable so I can parse it into an xmldom object. The database characterset is WE8ISO8859P1, so the multi-byte characters do not translate well.
    Is there any way to directly load/parse binary data into an xmldom object without having it go through the character translation, and have it recogized as utf-8?
    Or, is there a way to create and use a clob variable that is in a different characterset than the database characterset?
    The database version is 9.2.0.5
    Any suggestions greatly appreciated.
    Thanks,
    Mark

    In general the NCLOB data type is used for use. However XMLType does not support NCLOB for various valid technical reasons.
    In order for the XMLType based functions to work the database character set must be capable of representing all of the characters in the document. This means that in your case the only way you can process these documents is to convert the database character set to AL32UTF8.
    Sorry if this is bad news.

  • CLOB field conversion

    Hello,
    I'm doing an Access 97 -> Oracle 8.1.6 migration using OMWB 1.2.5.0.0.
    After having done a complete successful migration including
    modification of the source database, we notice that the Memo to CLOB
    conversion apparently was not completely successful: special
    characters such as the German umlauts are not displayed correctly, not
    within Access nor in plain SQL queries.
    "Normal" fields do not show that effect, but have been converted
    correctly.
    Is this a known issue?
    Any hint appreciated.
    Regards, Thomas Meyer
    null

    Hello again Thomas,
    I hate to be harbinger of bad news but there is no official workaround available. My only suggestion would be to avoid the CLOBS and use varchar but this in itself causes problems if the CLOB data is too large to for the varchar type to hold.
    As for estimating the timescale for the next release of the Oracle server.. sorry but yet again I cannot help there.
    As this is an RDBMS issue, contact Oracle support and have the bug's priority escalated.
    Not much help really. I do apologise.
    Regards
    Brian.

  • How to convert CLOB to varchar2 whose length is more than 4000

    Hi ,
    I have to retrive the CLOB data into varchar2 and spilt those comma seperated values into rows
    but i am getting following error
    " ORA-06502: PL/SQL: numeric or value error: character string buffer too small "
    the proc i used is like following :
    : create table test_clob (grp_id CLOB, id number)
    Create or replace proc test_clob(p_id number )
    Is
    V_clob CLOB;
    V_str varchar2(4000);
    V_main varchar2(30000);
    TYPE t_clob IS REF CURSOR;
    cur_clob t_clob;
    Begin
    Select grp_id
    Into v_str
    From test_clob
    Where id= p_id;
    ---converting column data in rows as I have to return the cursor as output
    V_main:= ' select grp_id from ( WITH t AS
    (SELECT REGEXP_SUBSTR(''' || v_str ||
    ''', ''[^,]+'', 1, LEVEL) txt
    FROM DUAL
    CONNECT BY LEVEL <=
    LENGTH(''' || v_str ||
    LENGTH(REPLACE(''' || v_str ||
    ''', '','')) + 1)
    SELECT REGEXP_SUBSTR(trim(txt), ''[^\,]+'', 1, 1) grp_id
    FROM t )';
    open cur_clob for ' select rtrim(xmlagg(xmlelement(e, grp_id || '','')).extract (''//text()'').getclobval (),'','') grp_id
    from ( '|| v_main||' ) ';
    loop
    fetch cur_clob
    into V_clob;
    exit when cur_clob %notfound;
    end loop;
    insert into test_clob
    values (p_id, v_clob);
    commit;
    End;
    Please help its very urgent

    957624 wrote:
    Hi ,
    I have to retrive the CLOB data into varchar2 and spilt those comma seperated values into rows
    but i am getting following error
    " ORA-06502: PL/SQL: numeric or value error: character string buffer too small "
    the proc i used is like following :
    : create table test_clob (grp_id CLOB, id number)
    Create or replace proc test_clob(p_id number )
    Is
    V_clob CLOB;
    V_str varchar2(4000);
    V_main varchar2(30000);
    TYPE t_clob IS REF CURSOR;
    cur_clob t_clob;
    Begin
    Select grp_id
    Into v_str
    From test_clob
    Where id= p_id;
    ---converting column data in rows as I have to return the cursor as output
    V_main:= ' select grp_id from ( WITH t AS
    (SELECT REGEXP_SUBSTR(''' || v_str ||
    ''', ''[^,]+'', 1, LEVEL) txt
    FROM DUAL
    CONNECT BY LEVEL <=
    LENGTH(''' || v_str ||
    LENGTH(REPLACE(''' || v_str ||
    ''', '','')) + 1)
    SELECT REGEXP_SUBSTR(trim(txt), ''[^\,]+'', 1, 1) grp_id
    FROM t )';
    open cur_clob for ' select rtrim(xmlagg(xmlelement(e, grp_id || '','')).extract (''//text()'').getclobval (),'','') grp_id
    from ( '|| v_main||' ) ';
    loop
    fetch cur_clob
    into V_clob;
    exit when cur_clob %notfound;
    end loop;
    insert into test_clob
    values (p_id, v_clob);
    commit;
    End;
    Please help its very urgentNo, nothing is urgent here and it is very rude to suggest it is, as well as it being a breach of the terms of use for the forums. Urgent issues relate to commercially live systems, and for those you need to raise a support request with Oracle Support. The forums are manned by volunteers with their own jobs to do, so suggesting they drop everything to help you urgently is very rude. Also, other people asking questions would like answers to theirs as soon as possible too, so suggesting your question is more urgent than theirs is also rude to those people. You will find that suggesting your question is urgent will actually prevent people from helping you on the forums as many people will simply choose to ignore you for your rudeness (either that or they'll be rude back)
    Please read {message:id=9360002} to learn how to ask a question properly.
    Now, in answer to your question...
    What is it you are really trying to do?
    If you have comma seperated data, why it is being stored like that in a CLOB? That seems like bad design for storing data.
    If the data is coming from a file, then you could consider using External Tables (or SQL*Loader) to load the comma seperated data in a structured way.
    If you really have data in a clob in comma seperated format, what are you wanting to do with it exactly i.e. what determines where the data should be split?
    Your code isn't clear, but it looks like, on the one hand you are splitting comma seperated data out of a string, and on the other hand you're turning it into XML to get a clob of data back.
    Please be clear by providing some example data and expected output, along with your database version as explained in the FAQ post I linked to above.

  • Issue with Xi File Receiver "Content Conversion" fixed length and kanji

    I need to create a fixed length file for a customer that has kanji (SJIS) characters in it.  The issue is when the length of the value is less than the fixed length.  It is padding out with spaces, but it is putting 2 bytes per space instead of one (But it seems to have counted the padding in characters...).
    .fieldFixedLengths: 8,6,40,40
    .fixedLengthTooShortHandling: Cut
    .fieldNames: date,time,name1,name2
    Receiver, please don't answer for sender.
    File Adapter

    Paul,
    Can you please tell what is coming in the output file if the values are:
    date:  062309
    time:   2240
    name1: hello
    name2: hello2
    When you put space here and if it is not showing correctly just to interpret you can use S which will stand for space.
    ---Satish

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

  • Conver BLOB column value to XML

    Oracle 10G
    My table has BLOB column my requirement is BLOB values needs to be populated in sequence file
    right now am using Java code to convert into XML then ETL tool to extrcat in to sequence file
    is is possible to pull directly into sequence file??
    Thanks in advance
    Edited by: Kalinga on Dec 8, 2009 9:19 PM

    The thread's subject refers to converting a BLOB to a XML, and you're posting mentions converting it to a sequence file...
    Not sure what you define a sequence file to be? Or what the intention is...
    BLOBs are used to store binary data. CLOBs are used to store character data.
    If the data is to be extracted as is into a file for a tool to use, the UTL_FILE can be used to read the contents of the BLOB/CLOB and write it to file.
    In other words, if you have a XML CLOB and an external tool needs the data as a file, there is no data conversion as such required. Only data dumping. Reading that CLOB (without conversion to other data types) and writing it to a file.
    If the CLOB data (in XML format) do needs to be processed as a XML DOM, then the SQL function XMLTYPE() can be used to convert that XML in the CLOB to a XML data type that can be processed using XML functions.
    If the CLOB data is in a non-XML format and it needs to be converted into XML and then spooled to a file, you need to write a parser that extracts that CLOB data into a SQL structure (e.g. a global temporary table), and then make use of XML functions and SQL to convert that data into a XML DOM.
    Once that is done, the XML DOM contents can be saved as a CLOB and written to an external file for external tools to use.
    If you can be more specific about what the actual problem is, and what (4 digit) Oracle version you are using, the forum can supply more detailed responses - instead of trying to guess what you are trying to achieve and what the meaning is of terms like "+sequence file+".

  • Conversion of a Base64EncodedXML CLOB to XMLTYPE

    I have an xml file which is base64 encoded and the base64 encoded file is stored as a clob. I want to do all the manipulation in PL/SQL and modify the clob column with one of xmltype
    Heres the steps I've got so far:
    i) convert the clob to a blob using dbms_lob.converttoclob
    ii) Since this is now in binary format I'm asusming that I don't need to cast to raw
    iii) decode the binary file using UTL_ENCODE.base64_decode
    iv) add an additional column  temp_xml as type xml_type
    v) update the temp_xml column with the values of the original column.
    update <tablename>
                   set temp_xml = xmltype(orig_clob_column) vi) At this stage I will see if I can read the xml in the new column and if all is successful, I will drop the orig_clob_column and rename temp_xml to orig_clob_column.
    If I've missed anything or anyone's got some gotchas for me, it would be appreciated.
    Message was edited by:
    Keith Jamieson
    Message was edited by:
    Keith Jamieson

    I am using Oracle 11g Windows and based on the example here:
    http://www.peakretrieval.com/plsql/Chapter16/Convert.sql
    create or replace PROCEDURE CONVERT_ME (
       v_blob_or_clob IN NUMBER,
       v_blob IN OUT BLOB,
       v_clob IN OUT CLOB,
       v_amount IN OUT NUMBER,
       v_blob_offset IN OUT NUMBER,
       v_clob_offset IN OUT NUMBER,
       v_lang_context IN OUT NUMBER,
       v_warning OUT NUMBER)
    AS
    BEGIN
       DBMS_LOB.OPEN(v_blob, DBMS_LOB.LOB_READWRITE);
       DBMS_LOB.OPEN(v_clob, DBMS_LOB.LOB_READWRITE);
       IF v_blob_or_clob = 0
       THEN
       DBMS_LOB.CONVERTTOBLOB(v_blob,
                              v_clob,
                              v_amount,
                              v_blob_offset,
                              v_clob_offset,
                              1,
                              v_lang_context,
                              v_warning);
       ELSE
       DBMS_LOB.CONVERTTOCLOB(v_clob,
                              v_blob,
                              v_amount,
                              v_clob_offset,
                              v_blob_offset,
                              1,
                              v_lang_context,
                              v_warning);
       END IF;
       DBMS_LOB.CLOSE(v_blob);
       DBMS_LOB.CLOSE(v_clob);
    END;When I run this sample code
    DECLARE
       v_clob_or_blob NUMBER;
       v_blob_locator BLOB;
       v_clob_locator CLOB;
       v_blob_offset NUMBER;
       v_clob_offset NUMBER;
       v_lang_context NUMBER := DBMS_LOB.DEFAULT_LANG_CTX;
       v_warning NUMBER;
       v_string_length NUMBER(10);
       v_source_locator BLOB;
       v_destination_locator BLOB;
       v_amount PLS_INTEGER;
       v_string CLOB;
    BEGIN
       -- CONVERT CLOB TO BLOB
       SELECT description
       INTO v_clob_locator
       FROM book_samples
       WHERE book_sample_id = 1
       FOR UPDATE;
       SELECT misc
       INTO v_blob_locator
       FROM book_samples
       WHERE book_sample_id = 1
       FOR UPDATE;
       v_string_length := DBMS_LOB.GETLENGTH(v_blob_locator);
       v_amount := DBMS_LOB.GETLENGTH(v_clob_locator);
       DBMS_OUTPUT.PUT_LINE('The initial length of the BLOB is: '||v_string_length);
            v_clob_or_blob := 0; -- Convert clob to blob
            v_clob_offset := 1;
            v_blob_offset := 1;
            CONVERT_ME(v_clob_or_blob,
                    v_blob_locator,
                    v_clob_locator,
                    v_amount,
                    v_blob_offset,
                    v_clob_offset,
                    v_lang_context,
                    v_warning);
       v_string_length := DBMS_LOB.GETLENGTH(v_blob_locator);
       DBMS_OUTPUT.PUT_LINE('The length of the BLOB post-conversion is: '||v_string_length);
       -- COPY BLOB FOR ONE ROW TO BLOB IN ANOTHER
       v_source_locator := v_blob_locator;
       SELECT misc
       INTO v_destination_locator
       FROM book_samples
       WHERE book_sample_id = 2
       FOR UPDATE;
       DBMS_LOB.COPY(v_destination_locator, v_source_locator, 32768, 1, 1);
       v_string_length := DBMS_LOB.GETLENGTH(v_destination_locator);
       DBMS_OUTPUT.PUT_LINE('The length of the BLOB post-copy is: '||v_string_length);
       -- COPY BLOB FOR RECORD 2 BACK TO A CLOB
       SELECT description
       INTO v_clob_locator
       FROM book_samples
       WHERE book_sample_id = 2
       FOR UPDATE;
       SELECT misc
       INTO v_blob_locator
       FROM book_samples
       WHERE book_sample_id = 2
       FOR UPDATE;
       v_string_length := DBMS_LOB.GETLENGTH(v_clob_locator);
       v_amount := DBMS_LOB.GETLENGTH(v_blob_locator);
       DBMS_OUTPUT.PUT_LINE('The initial length of the CLOB (record 2) is: '||v_string_length);
            v_clob_or_blob := 1; -- Convert blob to clob
            v_clob_offset := 1;
            v_blob_offset := 1;
            CONVERT_ME(v_clob_or_blob,
                    v_blob_locator,
                    v_clob_locator,
                    v_amount,
                    v_clob_offset,
                    v_blob_offset,
                    v_lang_context,
                    v_warning);
       v_string_length := DBMS_LOB.GETLENGTH(v_clob_locator);
       SELECT description
       INTO v_string
       FROM book_samples
       WHERE book_sample_id = 2;
       DBMS_OUTPUT.PUT_LINE('The length of the CLOB post-conversion is: '||v_string_length);
       DBMS_OUTPUT.PUT_LINE('     ');
       DBMS_OUTPUT.PUT_LINE('The converted CLOB');
       DBMS_OUTPUT.PUT_LINE('==================');
       DBMS_OUTPUT.PUT_LINE(SUBSTR(v_string,1,150));
       DBMS_OUTPUT.PUT_LINE(SUBSTR(v_string,151,300));
    EXCEPTION
       WHEN OTHERS
       THEN
          DBMS_OUTPUT.PUT_LINE('I''M BROKEN ... FIX ME!');
          DBMS_OUTPUT.PUT_LINE(SQLERRM);
    END;I get the following error:
    Length of blob before conversion
    The conver_me procedure is broken ...
    ORA-06502: PL/SQL: numeric or value error: invalid LOB locator specified: ORA-22275
    Length of blob after conversion

  • Field Length Cannot Be Reduced UDF

    I have a problem where i accidentally updated the Alphanumeric UDF to 100 and now i want to reduce its size and it prompts me with an error saying "Field Length Cannot Be Reduced". Any way to fix this?

    Hi David,
    You will not be able to Reduce Length of UDF once Created.
    This is Standard System Behavior.
    If its your requirement then Delete existing UDF and then Create again same UDF name with less Length.
    Hope this help
    Regards::::
    Atul Chakraborty

  • CLOB datatype to varchar

    Hi folks
    I have two columns which I am querying and they are both of datatype CLOB and which I bring my sql in my development environment these two columns are being displayed as nulls eventhough my sql works fine in Toad env. So, I'm pretty sure its because of the datatype of these two columns so could someone please advise on how I convert these types to varchar please.
    Thanks in advance
    Emma

    Hi,
    I had similar problem. My front end application is in Java. In my app. iam selecting the clob columns and converting the clob data into string (below is the method i used) before displaying it in my text area fields. Java string type can handle large amount of data. Converting the clob data into varchar within the pl/sql function will not work because we cann't assign large (clob) data to a varchar variable. Hope this helps.
    public String clobToString(Clob clob) throws SQLException,IOException {
         String textString = "";
         if (clob != null)
         // get stream from Clob Object
         java.io.Reader clobReader = clob.getCharacterStream();
         // find the length
         int textLength = (int)clob.length();
         // prepare a char array
         char[] textCharArray = new char[textLength];
         // read the data from the clob
         clobReader.read(textCharArray, 0, textLength);
         // convert char array to string
         textString = new String(textCharArray);
         // close the stream
         clobReader.close();
         return textString;
         }

  • Decimal Conversion Error During Export

    Hi All
    We are migrating our production system from HP-UX to SOLARIS and Informix to Oracle.
    During the export phase for the process SAPAPPL1 terminates with error :
    DbSl Trace: Error in decimal conversion. Length: 5, Decimals: 0
    (EXP) ERROR: DbSlExeRead: rc = 2, table "S011"
    (SQL error 0)
    error message returned by DbSl:
    I am not able to get hold of it.
    Kindly help, if someone has experience on the same.
    Regards
    Rahul

    Hi Rahul,
    What is your kernel release? Please confirm that you are in latest kernel and using the latest version of R3load.
    Regards,
    Satyabrat

  • Problem w. hash-value calculation for CLOB with DBMS_UTILITY.GET_HASH_VALUE

    Hello Oracle-Experts,
    I had to calculate hash-values for a corrorponding CLOB-field (see my post 'Buffer to small ORA-22835 error after migration from 9i to 10g' in forum 'database general').
    I calculate the hash-values with the DBMS_UTILITY.GET_HASH_VALUE, e.g:
         SQL> SELECT DBMS_UTILITY.GET_HASH_VALUE(LPAD('X',3998,'X'),1,POWER(2,30)) FROM dual;
         DBMS_UTILITY.GET_HASH_VALUE(LPAD('X',3998,'X'),1,POWER(2,30))
         1053896858
    Because the calculation failed with 10g I had taken a closer look at this function and realised the following results:
    VALUE                                             DBMS_UTILITY.GET_HASH_VALUE(VALUE,1,POWER(2,30))
    LPAD('X',3997,'X') 557754150
    LPAD('X',3998,'X')      1053896858
    LPAD('X',3999,'X')          888036750
    LPAD('X',4000,'X') 162062978
    LPAD('X',4001,'X')          162062978
    LPAD('X',4002,'X') 162062978
    LPAD('X',10000,'X') 162062978
    It seems to me that I can't use this function for clob-values with a length greater than 4000 characters because of collisions. Maybe someone with experience
    can give me a hint to handle this problem. Worst case i had to write my own CLOB_2_HASH function.
    TIA + Best regards
    Matthias

    Yeah, the 4000-byte limit would be a factor in working CLOBs. I if you only had 4000 bytes you would not need a CLOB in the first place.
    If you don't find something better then writing your own function might be the thing to do.

  • Clob Ora11g jdbc6 jar

    JAVA
    Initially our Java servlet used ojdbc4.jar to connect to oracle database . After migrating to Oracle 11g database, we are facing difficulties to read clob data returned from a oracle function. This was working fine in the previous DB versions.
    We later decided to use ojdbc6.jar to connect to Oracle 11g database but that didn't help either.
    The challenge is we were able to read clob data only upto a certain length using substring say around 4000 characters. If we try to read a entire clob data to its length the DB connection gets closed.
    TOAD
    We got the same issue "Connection Closed" issue when running a direct SQL using TOAD Oracle Client.
    I'm pretty sure the stored procedure works good as i'm able to query its length. I believe the problem lies within the clob serialization part by JDBC drivers.
    Any help is much appreciated!!!
    P.S: The oracle DB is located remotely and we usually establish VPN tunnel to connect to the Oracle DB instance for Java Servlet to communicate.
    Thank You
    Shashi

    You say a function. Do you have a resultset? If so, I believe it is possible to fetch data of a specific column through an InputStream. That would minimize the memory needed by the driver to provide the data to you. When you say the problem happens when you fetch more data, I am inclined to think it is because of a lack of memory that it fails. When things break inside the driver I can imagine that a cleanup step performed as a reaction to the failure is to close the connection to the database, but that's conjecture on my part.
    Note that what you say here does smell like a driver bug relating to function/procedure calls, so it might be worth reporting it to Oracle if you can figure out how.

  • Failure to Burn due to menu length

    My project for DL DVD completes the process to burn but hangs up at writing lead in and won't continue. My blank disk is kicked out. I get no error messages, but the bar regarding menu length is red. How do I reduce the menu length without shortening my overall movie. Can I remove the video from the menu and use picture icons to reduce length? If so do I need to delete encoding assets before trying to burn the dvd again? I am using a 5.0 idvd theme.

    The problem usually is that you have used a long movie clip in a menu drop zone (say a 15 minute clip) - even though you only display a short segment of the movie (say 30 seconds), the entire 15 minutes is included.
    Shorten your menu clips to say a minute or two.
    F Shippey

  • What are the conversion rules

    what are the conversion rules?can anybody give information on that?points wil be rewarded?

    hI..
    From sap help....
    <b>Conversion Rules for Elementary Data Types</b>
    There are ten predefined ABAP data types. There are 100 possible type combinations between these elementary data types. ABAP supports automatic type conversion and length adjustment for all of them except type D (date) and type T (time) fields which cannot be converted into each other.
    The following conversion tables define the rules for converting elementary data types for all possible combinations of source and target fields.
    C  D  F  I  N  P  STRING  T  X  XSTRING
    Source Type Character
    <b>
    Conversion table for source type C</b>
    Target
    Conversion
    C
    The target field is filled from left to right. If it is too long, it is filled with blanks from the right. If it is too short, the contents are truncated from the right.
    D
    The character field must contain an 8-character date in the format YYYYMMDD .
    F
    The contents of the source field must be a valid representation of a type F field as described in Literals.
    N
    Only the digits in the source field are copied. The field is right-justified and filled with trailing zeros.
    I, P
    The source field must contain the representation of a decimal number, that is, a sequence of digits with an optional sign and no more than one decimal point. The source field can contain blanks. If the target field is too short, an overflow may occur. This may cause the system to terminate the program.
    STRING
    The occupied length of the source field is copied. All trailing spaces are truncated.
    T
    The character field must contain a six-character time in HHMMSS format.
    X
    Since the character field must contain a hexadecimal string, the only valid characters are 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F. This string is packed as a hexadecimal number, transported left-justified, and filled with zeros or truncated on the right.
    XSTRING
    As for fields of type X, except that the target field is not filled with zeros.
    <b>Source Type Date</b>
    <b>Conversion table for source type D</b>
    <b>Target
    Conversion</b>
    C
    The date is transported left-justified without conversion.
    D
    Transport without conversion.
    F
    The date is converted into a packed number. The packed number is then converted into a floating point number (see corresponding table).
    N
    The date is transported left-justified without conversion and, if necessary, filled with zeros on the right.
    I, P
    The date is converted to the number of days since 01.01.0001.
    STRING
    The date is converted to a character field, which is then converted to a character string.
    T
    Not supported. Results in an error message during the syntax check or in a runtime error.
    X
    The date is converted to the number of days since 01.01.0001 in hexadecimal format.
    XSTRING
    As for fields of type X, except that only significant bytes are copied.
    <b>Source Type Floating Point Number
    Conversion table for source type F
    Target
    Conversion</b>
    C
    The floating point number is converted to the <mantissa>E<exponent> format and transported to the character field. The value of the mantissa lies between 1 and 10 unless the number is zero. The exponent is always signed. If the target field is too short, the mantissa is rounded. The length of the character field must be at least 6 bytes.
    D
    The source field is converted into a packed number. The packed number is then converted into a date field (see corresponding table).
    F
    Transport without conversion.
    N
    The source field is converted into a packed number. The packed number is then converted into a numeric text field (see corresponding table).
    I, P
    The floating point number is converted to an integer or fixed point value and, if necessary, rounded.
    STRING
    As for fields of type C, except that the maximum number of places is used for the mantissa (maximum precision). Despite this, different signs or exponents can lead to different string lengths.
    T
    The source field is converted into a packed number. The packed number is then converted into a time field (see corresponding table).
    X
    The source field is converted into a packed number. The packed number is then converted into a hexadecimal number (see corresponding table).
    XSTRING
    As for fields of type X, except that leading zeros are not copied.
    <b>Source Type Integer</b>
    Type I is always treated in the same way as type P without decimal places. Wherever type P is mentioned, the same applies to type I fields.
    <b>Source Type Numeric Text
    Conversion table for source type N</b>
    <b>Target
    Conversion</b>
    C
    The numeric field is treated like a character field. Leading zeros are retained.
    D
    The numeric field is converted into a character field. The character field is then converted into a date field (see corresponding table).
    F
    The numeric field is converted into a packed number. The packed number is then converted into a floating point number (see corresponding table).
    N
    The numeric field is transported right-justified and filled with zeros or truncated on the left.
    I, P
    The numeric field is interpreted as a number, and transferred to the target field, where it is right-justified, and adopts a plus sign. If the target field is too short, the program may be terminated.
    STRING
    As for fields of type C. The length of the character string matches the length of the numeric text.
    T
    The numeric field is converted into a character field. The character field is then converted into a time field (see corresponding table).
    X
    The numeric field is converted into a packed number. The packed number is then converted into a hexadecimal number (see corresponding table).
    XSTRING
    As for fields of type X, except that leading zeros are not copied.
    <b>Source Type Packed Number</b>
    If the program attribute Fixed point arithmetic is set, the system rounds type P fields according to the number of decimal places or fills them out with zeros.
    <b>Conversion table for source type P
    Target
    Conversion
    </b>
    C
    The packed field is transported right-justified to the character field, if required with a decimal point. The last position is reserved for the sign. Leading zeros appear as blanks. If the target field is too short, the sign is omitted for positive numbers. If this is still not sufficient, the field is truncated on the left. ABAP indicates the truncation with an asterisk (*). If you want the leading zeros to appear in the character field, use UNPACK instead of MOVE.
    D
    The packed field value represents the number of days since 01.01.0001 and is converted to a date in YYYYMMDD format.
    F
    The packed field is accepted and transported as a floating point number.
    N
    The packed field is rounded if necessary, unpacked, and then transported right-justified. The sign is omitted. If required, the target field is filled with zeros on the left.
    I, P
    A packed field is converted to type I. The resulting four bytes are placed into the target field right-justified. If the target field is too short, an overflow occurs. If the target field is longer, it is filled with zeros on the left.
    STRING
    As for fields of type C, except that leading zeros are not generated.
    T
    The packed field value represents the number of seconds since midnight and is converted to a time in HHMMSS format.
    X
    A packed field is converted to type I. The resulting four bytes are placed into the target field right-justified and in big-endian format. If the target field is too short, it is truncated from the left. If the target field is longer than 4, it is filled with zeros on the left. Negative numbers are represented by the two's complement (= bit complement +1).
    XSTRING
    As for fields of type X, except that leading zeros are not generated.
    <b>Source Type String
    Conversion table for source type STRING
    Target
    Conversion</b>
    C
    The target field is filled from left to right. If it is longer than the string, it is filled with trailing spaces. If it is too short, the contents are truncated from the right.
    D
    The string must contain an 8-character date in the format YYYYMMDD .
    F
    The contents of the string must be a valid representation of a type F field as described in Literals.
    N
    Only digits in the string are copied. The field is right-justified and filled with trailing zeros. If the target field is too short, it is truncated from the left.
    I, P
    The string must contain the representation of a decimal number, that is, a sequence of digits with an optional sign and no more than one decimal point. The source field can contain blanks. If the target field is too short, an overflow may occur. This may cause the system to terminate the program.
    STRING
    The source string is copied to the target string unconverted.
    T
    The string must contain a six-character time in HHMMSS format.
    X
    Since the character field must contain a hexadecimal-character string, the only valid characters are 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F. This character string is packed as a hexadecimal number, transported left-justified, and filled with zeros or truncated on the right.
    XSTRING
    As for target fields of type X, except that the field is not filled with zeros.
    <b>
    Source Type Time
    Conversion table for source type T
    Target
    Conversion</b>
    C
    The source field is transported left-justified without conversion.
    D
    Not supported. Results in an error message during the syntax check or in a runtime error.
    F
    The source field is converted into a packed number. The packed number is then converted into a floating point number (see corresponding table).
    N
    The date is converted into a character field. The character field is then converted into a numeric text field (see corresponding table).
    I, P
    The date is converted to the number of seconds since midnight.
    STRING
    The time is converted to a character field, which is then converted to a character string.
    T
    The date is transported left-justified without conversion and, if necessary, filled with zeros on the right.
    X
    The date is converted to the number of seconds since midnight in hexadecimal format.
    XSTRING
    As for fields of type X, except that only significant bytes are copied.
    <b>Source Type Hexadecimal Field
    Conversion table for source type X
    Target
    Conversion</b>
    C
    The value in the hexadecimal field is converted to a hexadecimal character string, transported left-justified to the target field, and filled with zeros.
    D
    The source field value represents the number of days since 01.01.0001 and is converted to a date in YYYYMMDD format.
    F
    The source field is converted into a packed number. The packed number is then converted into a floating point number (see corresponding table).
    N
    The source field is converted into a packed number. The packed number is then converted into a numeric text field (see corresponding table).
    I, P
    The value of the source field is interpreted as a hexadecimal number. It is converted to a packed decimal number and transported right-justified to the target field. If the hexadecimal field is longer than 4 bytes, only the last four bytes are converted. If it is too short, a runtime error may occur.
    STRING
    As for target fields of type C, except that the field is not filled with zeros. The length of the string is twice the length of the hexadecimal field.
    T
    The source field value represents the number of seconds since midnight and is converted to a time in HHMMSS format.
    X
    The value is transported left-justified and filled with X'00' on the right, if necessary.
    XSTRING
    The hexadecimal field is copied completely – that is, trailing zeros are not truncated.
    Source Type Byte Sequence
    Conversion table for source type XSTRING
    Target
    Conversion
    C
    The value in the byte sequence is converted to a hexadecimal character string, transported left-justified to the target field, and filled with zeros.
    D
    The byte sequence value represents the number of days since 01.01.0001 and is converted to a date in YYYYMMDD format.
    F
    The content of the byte sequence is converted into a packed number. The packed number is then converted into a floating point number (see corresponding table).
    N
    The content of the byte sequence is converted into a packed number. The packed number is then converted into a numeric text field (see corresponding table).
    I, P
    The content of the byte sequence is interpreted as a hexadecimal number. It is converted to a packed decimal number and transported right-justified to the target field. If the byte sequence is longer than 4 bytes, only the last four bytes are converted. If it is too short, a runtime error may occur.
    STRING
    As for target fields of type C, except that the field is not filled with zeros. The length of the string is twice the length of the byte sequence.
    T
    The byte sequence value represents the number of seconds since midnight and is converted to a time in HHMMSS format.
    X
    The byte sequence is transported left-justified and filled with X'00' on the right, if necessary.
    XSTRING
    The source byte sequence is copied to the target byte sequence unconverted.
    Conversion Rules for Internal Tables
    Internal tables can only be converted into other internal tables. You cannot convert them into structures or elementary fields.
    Internal tables are convertible if their line types are convertible. The convertibility of internal tables does not depend on the number of lines.
    <b>Conversion rules for internal tables:</b>
    Internal tables which have internal tables as their line type are convertible if the internal tables which define the line types are convertible.
    Internal tables which have line types that are structures with internal tables as components are convertible according to the conversion rules for structures if the structures are compatible.
    <b>Conversion Rules for Structures</b>
    ABAP has one rule for converting structures that do not contain internal tables as components. There are no conversion rules for structures that contain internal tables. You can only make assignments between structures that are compatible.
    You can combine convertible structures in the following combinations:
    Converting a structure into a non-compatible structure
    Converting elementary fields into structures
    Converting structures into elementary fields
    In each case, the system first converts all the structures concerned to type C fields and then performs the conversion between the two resulting elementary fields. The length of the type C fields is the sum of the lengths of the structure components. This rule applies to all operations using structures that do not contain internal tables.
    If a structure is aligned, the filler fields are also added to the length of the type C field.
    A non-aligned structure without filler fields:
    If you convert a structure into a shorter structure, the original structure is truncated. If you convert a structure into a longer one, the parts at the end are not initialized according to their type, but filled with blanks.
    It can make sense to assign a structure to another, incompatible, structure if, for example, the target structure is shorter than the source, and both structures have the same construction over the length of the shorter structure. However, numeric components of structures that are filled in incompatible assignments may contain nonsensical or invalid values that may cause runtime errors.
    DATA: BEGIN OF FS1,
    INT TYPE I VALUE 5,
    PACK TYPE P DECIMALS 2 VALUE ‘2.26’,
    TEXT(10) TYPE C VALUE ‘Fine text’,
    FLOAT TYPE F VALUE ‘1.234e+05’,
    DATA TYPE D VALUE ‘19950916’,
    END OF FS1.
    DATA: BEGIN OF FS2,
    INT TYPE I VALUE 3,
    PACK TYPE P DECIMALS 2 VALUE ‘72.34’,
    TEXT(5) TYPE C VALUE ‘Hello’,
    END OF FS2.
    WRITE: / FS1-INT, FS1-PACK; FS1-TEXT, FS1-FLOAT, FS1-DATE.
    WRITE: / FS2-INT, FS2-PACK, FS2-TEXT.
    MOVE FS1 TO FS2.
    WRITE: / FS2-INT, FS2-PACK, FS2-TEXT.
    Message was edited by:
            Rammohan Nagam

Maybe you are looking for

  • Forecast consumption situation not shown in Forecast tab-RRP3 View

    Hi, I have released Forecast(FA) from DP to SNP.I am able to see the forecasts in Product view Elements tab.But I am not able to see any Forecast consumption details and overview in Forecast tab of Product view.It is showing if i create forecast manu

  • Suggest file name in JFileChooser?

    I'm a newbie (student) to both Swing and Java in general. In using JFileChooser, It occurred to me that it would be nice to offer a suggested file name when saving files. For those of you who have used MS Word, when one saves a new file, Word offers

  • Default addresses

    I have a bad feeling what I want can't be done, but thought I'd check an make sure. I have several addresses I send mail from including some alias addresses for my @me.com account. I use these different addresses to send things to different people li

  • Emailing report through CMS (ScheduleToSMTP) - Need Multi-format support

    Hi All, I have implemented the ScheduleToSMTP method for sending my crystal report as an email attachment to the users. This has been done as described in the below link(s): http://devlibrary.businessobjects.com/businessobjectsxi/en/en/BOE_SDK/boesdk

  • Ghost of placed/linked psd cutout

    Hi Hope I can explain this InDesign Q clearly: PhotoShop file. With layer mask. Simple 'cutout'. Placed in InDesign as a psd file. Flat colour underneath the photo (in InDesign). Looks ok on screen, in PDF's or printed out on any design studio proofi