Exporting CLOB

While exporting a table containing a CLOB field I am getting the following error on Oracle 8.1.7. The length of the CLOB is more than 4K.
EXP-00056: ORACLE error 24801 encountered
ORA-24801: illegal parameter value in OCI lob function
anybody knows how to overcome this.
Mohan

Hi,
For a single schema you can do it like this:
schemas='your_schema_name_here'
include=TABLE:"IN (SELECT distinct table_name from dba_lobs where owner='your_schema_name_here' )"
Not sure you can do that for all schemas easily though.
Regards,
Rich

Similar Messages

  • Exporting CLOB data w/Oracle 8i

    Is there a way to export CLOB data from a table to an external
    file in a directory of our choice??? Our application
    specification is asking us to build this capability but I am
    unable to find any way to do this. Any assistance would be
    useful. Thanks a million!!
    null

    OCI really seems like the right way to do this. You know you have to use something like C to interact with the port. And the only Oracle stuff you are doing is an insert. You could even write the insert in a stored proc and call it from OCI. Below is an example of that. You should really give OCI a shot at this. I'm certain you can learn enough of it for this project.
    http://download-east.oracle.com/docs/cd/B10501_01/appdev.920/a96584/oci05bnd.htm#433702
    Tom Best

  • Export CLOB field (long= 4202083) to a file with UTL_FILE.PUT or PUT_LINE

    Hello,
    I'm trying to export a CLOB field to a txt file. It's a xml string in the CLOB. I have used different methods but the only which i can use is PUT, PUT_LINE.
    But:
    - PUT does only export the 32565 characters. I see that the output of l_pos is 4202084 but these are not exported. I have tried FFLUSH, but this gives a error or my syntax is not correct.
    - PUT_LINE is exporting the complete CLOB, but after every 32656 is new line is added and if I want to look with altove then I have to remove 129 times the new line. Thats not the way I want to go.
    Is it an idea, if it is possible, that I write 32565 chars to the buffer (file), read these 32565 from the buffer minus one (=without \r\n), delete the last 32565 chars from buffer and append/put the chars 32565 minus the \r\n to the buffer again. I hope there will be a better idea but....
    Has anybody an idea how I can solve this? Or what do I wrong?
    Any help would be appreciated.
    Beneath my code.
    Nico
    CREATE OR REPLACE DIRECTORY documents AS 'D:\TEST';
    SET SERVEROUTPUT ON
    DECLARE
      l_file    UTL_FILE.FILE_TYPE;
      l_clob    CLOB;
      l_buffer  VARCHAR2(32767);
      l_amount  BINARY_INTEGER := 32565;
      l_pos     INTEGER := 1;
      l_lengte  number;
      l_lineCount number := 0;
    BEGIN
      SELECT PAYLOAD
      INTO   l_clob
      FROM   icepayloadext ext
      WHERE  EXT.PAYLOADTYPE in ('POST')
        AND  substr(payload, 0, 2000) like '%181015%'
        AND  ext.LSTIME between to_date('10-10-2012 00:00:00', 'dd-mm-rrrr HH24:mi:ss') and to_date('10-10-2012 17:30:00', 'dd-mm-rrrr HH24:mi:ss');
      l_lengte := DBMS_LOB.GETLENGTH (l_clob);
      DBMS_OUTPUT.PUT_LINE('lengte clob veld: ' || l_lengte);
      l_file := UTL_FILE.fopen('DOCUMENTS', 'Sample1.txt', 'w', 32767);
      LOOP
        DBMS_LOB.read (l_clob, l_amount, l_pos, l_buffer);
        UTL_FILE.PUT(l_file, l_buffer);
        UTL_FILE.FFLUSH (l_file);
        --UTL_FILE.PUT_LINE(l_file,'alles geschreven');
        l_pos := l_pos + l_amount;
        DBMS_OUTPUT.PUT_LINE('Offset position: ' || l_pos);
        if (l_pos > l_lengte) then
            exit;
        end if;
      END LOOP;
      UTL_FILE.fclose(l_file);
    --EXCEPTION
      --WHEN OTHERS THEN
      --  DBMS_OUTPUT.put_line(SQLERRM);
        --UTL_FILE.fclose(l_file);
    END;
    /

    You can always try it the binary way:
    DECLARE
      l_file UTL_FILE.FILE_TYPE;
      l_clob CLOB;
      l_buffer VARCHAR2(32767);
      l_amount BINARY_INTEGER := 32565;
      l_pos INTEGER := 1;
      l_lengte number;
      l_lineCount number := 0;
    BEGIN
      l_clob := rpad( to_clob( 'test' ), 60000, 'test' );
      l_lengte := DBMS_LOB.GETLENGTH (l_clob);
    DBMS_OUTPUT.PUT_LINE('lengte clob veld: ' || l_lengte);
      l_file := UTL_FILE.fopen( 'MY_DIR', 'Sample1.txt', 'wb', 32767 );
      LOOP
        begin
          DBMS_LOB.read (l_clob, l_amount, l_pos, l_buffer);
        exception
          when no_data_found then exit;
        end;
    --    UTL_FILE.PUT_RAW( l_file, utl_raw.cast_to_raw( l_buffer ) ); -- file in database character set
        UTL_FILE.PUT_RAW( l_file, utl_i18n.string_to_raw( l_buffer, 'WE8MSWIN1252' ) );
        l_pos := l_pos + l_amount;
    DBMS_OUTPUT.PUT_LINE('Offset position: ' || l_pos);
      END LOOP;
      UTL_FILE.fclose(l_file);
    END;Anton

  • EA 2.1. Can't export CLOB columns.

    Hello:
    I don't know the reason why CLOB column export is not available or incorrect...
    In EA 2.1. version SQL developer "truncates" the CLOB field longer than 4000 characters..
    Why?
    *I can do that succesfully with TOAD.....*

    Because it's a missing feature.
    Any enhancement requests should go to the SQL Developer Exchange, so others can vote and add weight for possible future implementation.
    Regards,
    K.

  • V2.1 - Exporting CLOBS produces invalid SQL

    When you export a table that has a CLOB via either of these methods, the SQL it produces is invalid (Quotes, Blank Lines, etc.) :
    1. "Tools -> Database Export"
    2. Right-click on the results page, then export as "Insert" to the clipboard
    Insert into JAVASCRIPT (ID,FUNCTION_NAME,NAME,DESCRIPTION,VALID,FUNCTION,NUMBER_OF_ARGUMENTS,JAVASCRIPT,LAST_MODIFIED_DATE) values (26,'buildParameterizedUrl','Build Parameterized URL','Build Parameterized URL',1,1,3,'function buildParameterizedUrl(url, paramArray, valueArray)
    url += '?';
    var first = true;
    for(var i in paramArray)
    if(first)
    first = false;
    else
    url += '&';
    *url += paramArray[i] + '=' + valueArray;*
    return url;
    *',to_timestamp('16-JUL-09 09.52.30.000000000 AM','DD-MON-RR HH.MI.SS.FF AM'));*

    Hi,
    I encountered this problem since the EA and Vasan (one of the SQL Dev's team) gave the solution for this.
    >
    You can add the following in the sqldeveloper.conf to ensure that the driver doesn't report the column type of a DATE column as TIMESTAMP.
    AddVMOption -Doracle.jdbc.mapDateToTimestamp=false
    >
    As you can see on
    Re: 2.1 EA1: Problems on Date type columns
    I wonder, why this isn't included on the default installation of the product, since it is absolutely wrong to use Timestamp for Date type column on the first place.
    Regards,
    Buntoro

  • Exporting CLOB objects

    Hi all,
    I use 11gR2 version Database. I tried to migrate the character set of this database. After csscan, in the logfile I could see lot of CLOB objects that need conversion. It means that I must export those objects before applying csalter and then import them back in to the DB after csalter process. Now the question arises. How can I find all those CLOB objects in the database altogether and export them? Your assistance is appreciated kindly...
    Vimal.

    Hi,
    For a single schema you can do it like this:
    schemas='your_schema_name_here'
    include=TABLE:"IN (SELECT distinct table_name from dba_lobs where owner='your_schema_name_here' )"
    Not sure you can do that for all schemas easily though.
    Regards,
    Rich

  • Export CLOBs with text into their own file?

    I have a CLOB column in a table. I know it's text (XML Text to be more specific). I want to create a text file for the CLOB contents from each row in the result set of a query and I'd like to name each file based on the value in a different column in the query.
    So far I haven't hit upon how to do this ... can this be done in SQL Developer?
    If not, any chance it's something we'll see in a future version?
    thanks
    Craig

    We have a long list of features that we plan to get into the next release. There will of course be people disappointed, because we will not address every feature on the Exchange. However the team are working on them. We have a balance between getting bugs fixed, adding new features, picking up changes from the IDE and getting releases to the customer base in a timely fashion.
    However, quite some time back I suggested some of you put your heads together and add some extensions. There are few extensions to SQL Developer already. The extensibility of the product allows you to add and potentially share what you have done. I'm not suggestion you tackle this feature requested here, but just to address the comment that our features take longer than desired.
    Regards
    Sue

  • Export CLOB data in flat file from oracle 8i

    hi,
    I am in a bad situation. The oracle system crashed and i am trying to retrieve from backup. The backup was hot online backup and for some reason didnt happen correctly. Only thing remaining is DBF and redo log. I somehow managed to recreated the control files. But i cannot login to oracle using sqlplus using any user. Only thing that works is server manager and connect as internal.
    Now i need to retrieve data from tables having CLOB data to a flat file.
    Any suggestions?
    using oracle 8.1.

    The backup was hot online backup and for some reason didnt happen correctly.How did you verify this?
    But i cannot login to oracle using sqlplus using any userDo you get any error?

  • Export data from table with CLOB column

    DB: Oracle10g
    SQLDeveloper: 1.0
    OS: windows xp for sqldeveloper
    Linux for Oracle db
    we have a table with two CLOB columns. We want to export the data to either text or csv. But the CLOB columns don't show up in the columns that can be exported.
    How do I export CLOB data from SQL Developer?
    Regards,
    Lonneke

    I don't think this is a good protection: you can have these characters in VARCHAR anyway, and this way you "throw the baby out with the bath water". Not mentioning that right now also immune formats like HTML are also limited.

  • Data moving between Oracle 10g with CLOB fields

    Hi all,
    I have a trouble in migrate data between Oracle 10g with different platform. The worst thing is that I don't have a DBA account for the DB importing data. I think I can't use IMP or IMPDP in this way. So I seek help from sql developer, but it seems having another problem with CLOB data moving.
    Re: EA2 : SQL Developer 1.5 : export data CLOB columns
    in the thread, I found someone wrote this:
    - SQL Developer v1.5 EA2 - exports first 4000 chars (which is anyway too small for me, because my CLOBs are larger - if they were smaller, I would have made them VARCHAR2s instead!).
    I would like to ask:
    1, What SQL Developer v1.5 EA2 is? Is it the Data Modeling one?
    2, How to export table data with CLOB with SQL Developer v1.5 EA2? Since 4000 chars is enough for me to use.
    OR any other method to export CLOB but not IMP / IMPDP ?
    Now I am using the spool of sqlplus to export CLOB.
    Many thanks,

    1. The EAs are Early Adapters, betas, so you should expect the same behaviour from the latest 1.5.4 production release.
    2. Exports can be done with the Database Export tool, through the table's context menu in the navigator tree or the result grid's context menu.
    Have fun,
    K.

  • CLOB how to?

    Hi all
    I have JPublished a pl/sql package and JDeveloper has created a xxx.sqlj file with the desired method:
    public void foo (String argOne, oracle.sql.CLOB argTwo[]) throws SQLException
    #sql [getConnectionContext()] { CALL INV.REGAKTIV_PCK.XML_INDREVAERDI(
    :argOne,
    :OUT (argTwo[0])) };
    But how do I Call this method? The method expects an arguments of CLOBs with size 1 to be able to store the result in. But this Clob array must be created prior to calling foo() but how?
    Any help appreciated

    Already answered here, I think this is what you'll need http://stackoverflow.com/questions/22807316/oracle-blob-data-are-missing-in-my-export-file
    It's a common issue for SQL developer when exporting CLOBs. If you have the facility try using datapump instead, it's easy to use and if needs be you can use the dbms_datapump api, only difference being it will pump out to a local directory object.

  • Dbms_lob.getlength() returns different source and destination lengths

    I am fairly new to PL/SQL so maybe this is an obvious problem but here goes. I am updating a clob field with a text file ~5KB in size. The field updates fine (as far as I can tell). Before I update the field, I open the source file as a bfile and then inquire the length using dbms_lob.getlength(). I then update the clob field using dbms_lob.loadclobfromfile(). This seems to work fine. However, when I use dbms_lob.getlength() on the destination object returned by dbms_lob.loadclobfromfile(), I get a length 3 characters less than then the source object (5072 vs 5075). Both the source and destination offsets are set to 1.
    Probing on what documentation I could find, I found this at http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28419/d_lob.htm#i998484:
    "The length returned for a BFILE includes the EOF, if it exists. Any 0-byte or space filler in the LOB caused by previous ERASE or WRITE operations is also included in the length count. The length of an empty internal LOB is 0."
    I did not create the source file and I believe it is a Unix type file (because of the lack of CRs) and I am running on Windows 7. I am also using 11g Express. Could the use of a Unix-type file for a CLOB on a Windows system be causing this character count difference?
    Once I found this issue I can work around it. I just want to understand what is going on.
    Thanks to all who look at this.

    The EOF and the LF versus CR/LF could influence the count difference, yes.
    Another explain could possibly be character set conversions. The BFILE I believe counts bytes, a CLOB would count "characters" - so if the source happens to contain a few multibyte characters (UTF), then the byte count would be larger than the character count.
    To help you find the cause for your exact file, then I can suggest a couple of things you might do to explore the issue:
    <li>Load the file into a BLOB instead of a CLOB and see what getlength() returns for the BLOB. BLOBs would also do byte counts and not try to treat the source as text.
    <li>Save the CLOB back into the filesystem and compare the original file with the exported CLOB and check the differences with some filecompare tool.

  • Dbms_lob.getlength() returns different values

    Hi !
    I am not a developer.. So, possibly cannot answer developer specific question.
    We have two instances running on 10.2.0.4 but both giving different value for
    declare
         xml varchar2(32676) :=
    'SELECT XT_STRATEGY, ACCT_DESCRIPTION,sum(MON_PL) PL_MON ,sum(TUE_PL) PL_TUE,sum(WED_PL) PL_WED ,sum(THU_PL) PL_THU, sum(FRI_PL) PL_FRI, sum(WTD_PL) PL_WTDPL,sum(WTD_PREMIUM_PL) PL_WTDPRMPL, sum(MTD_PL) PL_MARKPL,sum(MTD_PREMIUM_PL) PL_MTDPRMPL,sum(YTD_PL) PL_YTDPL,sum(YTD_PREMIUM_PL) PL_YTDPRMPL,
                   DLC_REGION,DLC_ENTITY  FROM (SELECT xt_strategy, acct_description ,case when  blankout_date  < to_char( to_date(    fv[EOD]        )+ (1 -to_char(to_date(to_date(    fv[EOD]        )),''D'')))  then 0 else MON_PL end as MON_PL, case when  blankout_date  < to_char( to_date(    fv[EOD]        )+ (1 -to_char(to_date(to_date(    fv[EOD]        )),''D''))) then 0 else tue_pl end as tue_pl,
    case when  blankout_date  < to_char( to_date(    fv[EOD]        )+ (1 -to_char(to_date(to_date(    fv[EOD]        )),''D'')))  then 0 else WED_PL end as WED_PL, case when  blankout_date  < to_char( to_date(    fv[EOD]        )+ (1 -to_char(to_date(to_date(    fv[EOD]        )),''D'')))  then 0 else THU_PL end as  THU_PL,
    case when  blankout_date  < to_char( to_date(    fv[EOD]        )+ (1 -to_char(to_date(to_date(    fv[EOD]        )),''D'')))  then 0 else FRI_PL   end as  FRI_PL, case when  blankout_date  < to_char( to_date(    fv[EOD]        )+ (1 -to_char(to_date(to_date(    fv[EOD]        )),''D'')))  then 0 else WTD_PL   end as  WTD_PL,
    case when  blankout_date  < to_char( to_date(    fv[EOD]        )+ (1 -to_char(to_date(to_date(    fv[EOD]        )),''D'')))  then 0  else WTD_PREMIUM_PL   end as  WTD_PREMIUM_PL,
    case when  blankout_date  < (select actual_date from tbl_date where date_type = ''PLMonthStart'' and to_char(actual_date, ''MMYYYY'') = to_char(to_date(    fv[EOD]        ),''MMYYYY'')) then 0 else mtd_pl end as mtd_pl,
    case when  blankout_date  < (select actual_date from tbl_date where date_type = ''PLMonthStart'' and to_char(actual_date, ''MMYYYY'') = to_char(to_date(    fv[EOD]        ),''MMYYYY'')) then 0 else MTD_PREMIUM_PL end as MTD_PREMIUM_PL,
    case when  blankout_date  < (select to_date(''01-JAN-''|| to_char(to_date((fv[EOD]),''DD-MON-YYYY''),''YYYY''),''DD-MON-YYYY'') from tbl_business_date) then 0 else ytd_PL end as ytd_PL,
    case when  blankout_date  < (select to_date(''01-JAN-''|| to_char(to_date((fv[EOD]),''DD-MON-YYYY''),''YYYY''),''DD-MON-YYYY'') from tbl_business_date) then 0 else ytd_premium_PL end as ytd_premium_PL,
    IN_STRIKECURR, IN_QUOTEDCUR, case dlc_region when ''LON'' then ''LN'' when ''NYC'' then ''NY'' when ''TOK'' then ''TK'' else dlc_region
    end as DLC_REGION, DLC_ENTITY,DTL_REFERENCE,TRADE_STATE,blankout_date
    FROM (select a.bo_book_id as xt_strategy, a.bo_book_id  as acct_description , b.mon_pl, b.tue_pl, b.wed_pl,b.thu_pl,b.fri_pl,b.wtd_pl, b.wtd_premium_pl , b.mtd_pl , b.mtd_premium_pl, b.ytd_pl, b.ytd_premium_pl,
               a.BASE_CCY as IN_STRIKECURR, A.QUOTED_CCY AS IN_QUOTEDCUR,  a.region_code as dlc_region, a.entity_acronym  as dlc_entity, TP.EBI_TRADE_ID AS DTL_REFERENCE, a.trade_state,
         case when a.trade_state in  (7,8,13) then a.amendment_date when a.maturity_date > nvl(a.premium_settlement_date, to_date(''01-JAN-1900'')) then
              Case when a.trade_state in  (4,5 ) then  trunc(a.updated_date) else a.maturity_date end else a.premium_settlement_date end as blankout_date  FROM      TBL_TRADE_HIST A
         join vw_feed_downstream_trade_id tp on a.trade_id = tp.trade_id and tp.mapping_source_name = ''ramfx''
       join tbl_pl b on a.trade_id = b.trade_id and a.version = b.trade_version      and b.pl_date = (select max(pl_date) from tbl_pl d where a.trade_id  = d.trade_id and pl_date <=     fv[EOD]        )
       join tbl_bo_book bk on a.bo_book_id = bk.bo_book_id  and bk.business_Area = ''OPTIONS''
       where b.pl_date <     fv[EOD] 
       AND      NOT EXISTS (SELECT 1 FROM TBL_EOD_TRADES D WHERE A.TRADE_ID = D.TRADE_ID AND  D.BUSINESS_DATE =     fv[EOD]        )
    UNION
        SELECT A.XT_STRATEGY,     A.ACCT_DESCRIPTION, C.MON_PL,C.TUE_PL, C.WED_PL,C.THU_PL, C.FRI_PL,C.WTD_PL,C.WTD_PREMIUM_PL,C.MTD_PL,C.MTD_PREMIUM_PL,C.YTD_PL,C.YTD_PREMIUM_PL,
             A.IN_STRIKECURR, A.IN_QUOTEDCUR,  A.DLC_REGION,A.DLC_ENTITY, A.DTL_REFERENCE , a.trade_state , case when a.trade_state in  (7,8,13) then  a.DLC_BUSDATEUPD when a.IN_EXPIRATION > nvl(a.XT_SETTLEDATE, to_date(''01-JAN-1900'')) then a.IN_EXPIRATION else a.XT_SETTLEDATE end as blankout_date
        FROM VW_EBI_FEED A , TBL_EOD_TRADES B , TBL_PL C
        WHERE A.TRADE_ID                    = B.TRADE_ID   AND      A.VERSION  = B.TRADE_VERSION   AND      A.TRADE_ID    = C.TRADE_ID
        AND      A.ACCT_RISKFEED             = ''D''    AND      A.DLC_DEALSTATE   in  (''LIVE'',''PENDING'',''CANCELLED'',''REVERSED'')    AND      A.VERSION                 = C.TRADE_VERSION
        AND      B.BUSINESS_DATE         =     to_date(    fv[EOD]          ,''DD-MON-YYYY'')    AND C.PL_DATE   =    to_date(    fv[EOD]          ,''DD-MON-YYYY'')
    UNION
        SELECT A.BO_BOOK_ID  AS XT_STRATEGY , A.BO_BOOK_ID  AS ACCT_DESCRIPTION,   a.MON_PL , a.TUE_PL , a.WED_PL, a.THU_PL , a.FRI_PL, a.WTD_PL ,a.WTD_PREMIUM_PL , a.mtd_pl,  a.MTD_PREMIUM_PL,a.ytd_PL ,  a.ytd_premium_PL,A.BASE_CCY AS IN_STRIKECURR,A.QUOTED_CCY AS IN_QUOTEDCUR,
                       A.REGION_CODE as dlc_region ,A.ENTITY_ACRONYM AS DLC_ENTITY, A.MAPPING_SOURCE_ID AS DTL_REFERENCE, 12 as trade_state , a.PL_DATE as blankout_date
                                        FROM TBL_PL_ARCH A , tbl_bo_book b  where a.bo_book_id = b.bo_book_id  and      b.business_area = ''OPTIONS''
    union
    select d.bo_book_id as xt_strategy, d.bo_book_id as acct_description, case  when to_char(b.pl_date,''D'') = 6 then (b.inception_pl + b.inception_premium_pl ) else  (b.mon_pl * -1) end as mon_pl ,
             case when to_char(b.pl_date,''D'') = 2 then  (b.inception_pl + b.inception_premium_pl )  when to_char(b.pl_date,''D'')  > 2 then  (b.tue_PL  * -1) else 0 end as tue_pl,  case when to_char(b.pl_date,''D'') = 3 then  (b.inception_pl + b.inception_premium_pl )  when to_char(b.pl_date,''D'') > 3 then  (b.wed_pl * -1) else 0 end as wed_pl ,
               case when to_char(b.pl_date,''D'') = 4 then  (b.inception_pl + b.inception_premium_pl)  when to_char(b.pl_date,''D'') > 4 then  (b.thu_pl * -1) else 0 end as thu_pl ,case when to_char(b.pl_date,''D'') = 5 then  (b.inception_pl + b.inception_premium_pl)  when to_char(b.pl_date,''D'') > 5 then  (b.fri_pl * -1) else 0 end as fri_pl ,
             (b.mon_pl + b.tue_pl + b.wed_pl  + b.thu_pl + b.fri_pl) * -1 + (b.inception_pl + b.inception_premium_pl)  as wtd_pl, case when b.wtd_premium_pl <> 0 then b.wtd_premium_pl *-1 + (b.inception_premium_pl) else b.wtd_premium_pl end as wtd_premium_pl  ,       case when b.mtd_pl <> 0 then  b.mtd_pl * -1 + (b.inception_pl) else b.mtd_pl end as mtd_pl ,
             case when b.mtd_premium_pl <> 0 then b.mtd_premium_pl * -1 +  (b.inception_premium_pl ) else b.mtd_premium_pl end as mtd_premium_pl,   case when b.ytd_pl <> 0 then b.ytd_pl * -1 + (b.inception_pl) else b.ytd_pl  end as ytd_pl,
             case when b.ytd_premium_pl <> 0 then b.ytd_premium_pl * -1 + (b.inception_premium_pl) else b.ytd_premium_pl  end as ytd_premium_pl ,
              c.base_ccy as IN_STRIKECURR,c.quoted_ccy as IN_QUOTEDCUR,c.region_code as dlc_region,c.entity_acronym as dlc_entity, to_char(c.trade_id) as dtl_reference,
            8 as trade_state,  case when to_char(b.pl_date,''D'') = 6 then b.pl_date + 2 else b.pl_date end as blankout_date
    from tbl_trade_hist a
    join tbl_pl b on a.trade_id = b.trade_id and a.version = b.trade_version
    join tbl_trade_hist c on a.tradE_id = c.trade_id
    join tbl_pl d on c.trade_id = d.trade_id and c.version = d.trade_version and d.pl_date =   (select max(e.pl_date) from tbl_pl e where c.trade_id = e.trade_id and e.pl_date <= c.amendment_date)
    join tbl_bo_book f on a.bo_book_id = f.bo_book_id and f.business_area = ''OPTIONS''
    where (b.bo_book_id <> d.bo_book_id or a.region_code <> c.region_code or a.entity_acronym <> c.entity_acronym or a.base_ccy <> c.base_ccy or a.quoted_ccy <> c.quoted_ccy)
    and      d.pl_date  -  b.pl_date =  case when to_char(d.pl_date,''DAY'') = ''MON'' then  3 else  1 end
    and      d.pl_date <= to_date(    fv[EOD]          ,''DD-MON-YYYY'')
    union all
    select b.bo_book_id as xt_strategy,  b.bo_book_id as acct_description,case  when to_char(b.pl_date,''D'') = 6 then (b.inception_pl * -1 + b.inception_premium_pl * -1) else  (b.mon_pl ) end as mon_pl ,
             case when to_char(b.pl_date,''D'') = 2 then  (b.inception_pl * -1 + b.inception_premium_pl * -1)  when to_char(b.pl_date,''D'')  > 2 then  (b.tue_PL) else 0 end as tue_pl, case when to_char(b.pl_date,''D'') = 3 then  (b.inception_pl * -1  + b.inception_premium_pl * -1 )  when to_char(b.pl_date,''D'') > 3 then  (b.wed_pl) else 0 end as wed_pl ,
               case when to_char(b.pl_date,''D'') = 4 then  (b.inception_pl * -1 +  b.inception_premium_pl * -1 )   when to_char(b.pl_date,''D'') > 4 then  (b.thu_pl ) else 0 end as thu_pl , case when to_char(b.pl_date,''D'') = 5 then  (b.inception_pl *-1 + b.inception_premium_pl * -1)  when to_char(b.pl_date,''D'') > 5 then  (b.fri_pl) else 0 end as fri_pl ,
             (b.mon_pl + b.tue_pl + b.wed_pl  + b.thu_pl + b.fri_pl)  + (b.inception_pl* -1 + b.inception_premium_pl * -1)  as wtd_pl, case when b.wtd_premium_pl <> 0 then b.wtd_premium_pl + (b.inception_premium_pl * -1) else b.wtd_premium_pl end as wtd_premium_pl  ,   case when b.mtd_pl <> 0 then  b.mtd_pl + (b.inception_pl * -1) else b.mtd_pl end as mtd_pl ,
             case when b.mtd_premium_pl <> 0 then b.mtd_premium_pl +  (b.inception_premium_pl * -1) else b.mtd_premium_pl end as mtd_premium_pl,  case when b.ytd_pl <> 0 then b.ytd_pl + (b.inception_pl * -1) else b.ytd_pl  end as ytd_pl,
             case when b.ytd_premium_pl <> 0 then b.ytd_premium_pl + (b.inception_premium_pl * -1) else b.ytd_premium_pl  end as ytd_premium_pl ,
             a.base_ccy as IN_STRIKECURR, a.quoted_ccy as IN_QUOTEDCUR, a.region_code as dlc_region,a.entity_acronym as dlc_entity, to_char(a.trade_id) as dtl_reference, 8 as trade_state,
            case when to_char(b.pl_date,''D'') = 6 then b.pl_date + 2 else b.pl_date end as blankout_date
    from tbl_trade_hist a
    join tbl_pl b on a.trade_id = b.trade_id and a.version = b.trade_version
    join tbl_trade_hist c on a.tradE_id = c.trade_id join tbl_pl d on c.trade_id = d.trade_id and c.version = d.trade_version and d.pl_date =   (select max(e.pl_date) from tbl_pl e where c.trade_id = e.trade_id and e.pl_date <= c.amendment_date)
    join tbl_bo_book f on a.bo_book_id = f.bo_book_id and f.business_area = ''OPTIONS''
    where (b.bo_book_id <> d.bo_book_id or a.region_code <> c.region_code or a.entity_acronym <> c.entity_acronym or a.base_ccy <> c.base_ccy or a.quoted_ccy <> c.quoted_ccy)
    and      d.pl_date  -  b.pl_date =  case  when to_char(d.pl_date,''DAY'') = ''MON'' then  3 else  1 end and      d.pl_date   <= to_date(  fv[EOD]  ,''DD-MON-YYYY'') ))
    group by xt_strategy,ACCT_DESCRIPTION,DLC_REGION,DLC_ENTITY';
    c clob;
    s varchar2(25000);
    i numeric := 424;
    begin
         c := xml;
       dbms_output.put_line('length of clob: ' || dbms_lob.getlength(c));
       dbms_output.put_line('split clob at: ' || i);
       dbms_output.put_line('desired substring length: ' || to_char(dbms_lob.getlength(c) - i));
       s := dbms_lob.substr(c, dbms_lob.getlength(c) - i, i + 1);
       dbms_output.put_line('length of substring: ' || length(s));
    end;I checked for the database characterset and they are same - AL32UTF8
    The result we get is
    Output from MD1 database
    length of clob: 10616
    split clob at: 424
    desired substring length: 10192
    length of substring: 10192
    Output from MD2 database
    length of clob: 10616
    split clob at: 424
    desired substring length: 10192
    length of substring: 8191Any idea why there is this discrepancy ?
    Edited by: USER101 on Feb 19, 2010 4:24 PM

    The EOF and the LF versus CR/LF could influence the count difference, yes.
    Another explain could possibly be character set conversions. The BFILE I believe counts bytes, a CLOB would count "characters" - so if the source happens to contain a few multibyte characters (UTF), then the byte count would be larger than the character count.
    To help you find the cause for your exact file, then I can suggest a couple of things you might do to explore the issue:
    <li>Load the file into a BLOB instead of a CLOB and see what getlength() returns for the BLOB. BLOBs would also do byte counts and not try to treat the source as text.
    <li>Save the CLOB back into the filesystem and compare the original file with the exported CLOB and check the differences with some filecompare tool.

  • Can I upgrade my Oracle Clint also ?   9.2.0.7 compatible??

    Can I upgrade my Oracle Clint also ?
    I am using oracle client version 9.2.0.1 on windows 2000 SP4, but my database is 9.2.0.7 on linux. I because of version incompatibility I am not able to export clob/blob data from the server. I am getting the error EXP-00003: no storage definition found for segment(6, 153537)
    For this case how can I upgrade my Oracle Client to function on my database properly?

    Hi, you must instal the patch 4163445, this patch is for server and client.
    Regards
    Angel

  • Importing and Exporting Data with a Clob datatype with HTML DB

    I would like to know what to do and what to be aware of when Importing and Exporting data with a Clob Datatype with HTML DB?

    Colin - what kind of import/export operation would that be, which pages are you referring to?
    Scott

Maybe you are looking for

  • File to File transfer with a Mail Confirmation using BPM

    Hi everyone, I'm trying to configure a scenario where I will pick a file, send it to the appropriate receiver and send an acknowledgement mail to a mail account. I have created necessary business process, interfaces, mappings, data types in IR. Also,

  • What does the close button on the cookie permission dialog do?

    If I don't choose Allow, Allow for Session or Deny, but instead just close the dialog, is there an exception set for that site? Is a cookie stored or refused?

  • Uninstalling oracle 9i/10g & installing oracle 9i

    Dear Experts, As I am using ECC5.0 on oracle database10g and HPUX as OS. I am facing problem with SAP startup.When I try to open database it is saying need to recover some backup datafiles which i dont have backup.This is a development system. Here I

  • In point in TimeView

    Hi everyone ! i have a sequence with a primatte Keying, at the begining i put this sequence at frame -722. by an error i move this at -780, i want to correct my error but impossible, i just can put this sequence at 720 or 727.... impossible to go to

  • Windows Mobile Device Emulator doesn't display when cradled

    Good afternoon,I am trying to get the WM Device Emulator to function on my Windows 7 Pro 64bit machine. I have tried quite a few things and am still stuck on the issue.This is a new install which is where the problem is. I am installing Windows Mobil