Dbms_lob.instr question

Hello,
I have a field that holds CLOBs in the database. I have a textfield in which the user can enter a target string, then I hope to use dbms_lob.instr to search for the target string in CLOB. The code looks like: dbms_lob.instr(upper(I.COMMENTS),upper(nvl(:P26_SEARCH_NAME,I.COMMENTS))). If I replace the textfield value :P26_SEARCH_NAME with a string, the line works fine, but the current line returns the error
ORA-22835: Buffer too small for CLOB to CHAR or BLOB to RAW conversion (actual: 6250, maximum: 4000) Can someone offer some help with a fix?

Steven - Try v('P26_SEARCH_NAME') as a test to see if it makes any difference. If not, I can look at your test case if you put it on apex.oracle.com.
Scott

Similar Messages

  • DBMS_LOB.INSTR - Searching for a pattern

    Hi
    I have a program supporting several databases. F.ex SQL2000 and Oracle 8/9.
    The field in question, text, might contain a lot of characters. In Oracle, it's a CLOB,
    on SQL2000 it's a varchar. It is not possible for me to alter the database-structure in
    any ways at this moment. The database-schema is locked.
    My question is pretty simple, you have probably seen it before.
    In SQL2000 I can use this query:
    select count(*) from crm5.text where text like 'n%'.
    The result returned = 8.
    The same on Oracle will be somewhat like:
    select count(*) from crm5.text where dbms_lob.instr( text, 'n') > 0
    The result returned = 29.
    The databases has the same data.
    It seems to me that the dbms_lob.instr
    does a (case-sensitive) query like this:
    select count(*) from crm5.text where text like '%n%
    Is this the right assumption? How can I get the correct number
    of rows and do the search case-insensitive at the same time not
    killing the performance of the database? We use a pretty smart
    little thing on "normal" LIKE. But how can we do this with the
    CLOB?
    Regards,
    Ivar

    Found the solution.
    On Oracle 9, use LIKE as you want.
    On Oracle 8, use
    select count(*) from crm5.text
    where dbms_lob.instr( text, 'N') = 1
    or dbms_lob.instr( text, 'n') = 1.
    Ivar (same account, different mail-address).

  • DBMS_LOB.instr (looking backwards for a string)

    I am trying to find the position of the first instance of a string ('><'), but staring at a position in the CLOB (not the start) and working backwards
    I thought this may work:
    num := DBMS_LOB.instr(L_CLOB, '><', 5000, -1);
    But unfortunately it returns nothing....
    Anyone able to help me?
    Thanks,

    I think you've got the parameters scrambled. Try this:
       num := DBMS_LOB.instr(L_CLOB, '><', -1, 1);Cheers, APC

  • Can dbms_lob.instr have end position?

    I am extracting data from xml using dbms_lob utility and the pattern in XML is as below.
    <Atag>
    <Btag>
    <Ctag>value</Ctag>
    </Btag>
    <Btag>
    <Ctag>value</Ctag>
    <Dtag>value</Dtag>
    </Btag>
    <Btag>
    <Ctag>value</Ctag>
    <Dtag>value</Dtag>
    </Btag>
    </Atag>
    I want to extract all tag values inside <Btag> which will be nohting but Ctag and Dtag values. There can be any occurence of <Btag> in this xml. When I use like this,
    val:=0;
    <LOOP>
    val1:=dbms_lob.instr(xml,'<Btag>',val);
    val2:=dbms_lob.instr(xml,'</Btag>,val1);
    val3:=case(val1) when 0 then 0 else dbms_lob.instr(xml,'<Ctag>,val1) end;
    val4:=case(val3) when 0 then 0 else dbms_lob.instr(xml,'</Ctag>,val3) end;
    val5:=case(val1) when 0 then 0 else dbms_lob.instr(xml,'<Dtag>,val1) end;
    val6:=case(val5) when 0 then 0 else dbms_lob.instr(xml,'</Dtag>,val5) end;
    In this case as <Dtag> doesnt exist inside the first occurence of <Btag>, so it gets the value from the next one which is not what I require. I want that to be set to null/zero so for which I want to search only between the first occurence of <Btag> and </Btag>.
    I know it is confusing but can some one of you tell me how to go and find the values of <Ctag> and <Dtag> between each occurence of <Btag>. If they are not present I want the value to be set to zero/null.
    Thanks in advance.

    test@ora>
    test@ora> @ver1
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    1 row selected.
    test@ora>
    test@ora>
    test@ora> --
    test@ora> with t as (
      2    select '<Atag>
      3  <Btag>
      4  <Ctag>Tootsie</Ctag>
      5  </Btag>
      6  <Btag>
      7  <Ctag>Psycho</Ctag>
      8  <Dtag>Casablanca</Dtag>
      9  </Btag>
    10  <Btag>
    11  <Ctag>Goodfellas</Ctag>
    12  <Dtag>Chinatown</Dtag>
    13  </Btag>
    14  </Atag>' as x from dual)
    15  --
    16  select
    17    x,
    18    regexp_replace(modx,'(.*?)<Btag>(.*?)</Btag>.*$','\2',1,1) as txt1,
    19    regexp_replace(modx,'(.*?)(<Btag>(.*?)</Btag>){1}<Btag>(.*?)</Btag>.*$','\4',1,1) as txt2,
    20    regexp_replace(modx,'(.*?)(<Btag>(.*?)</Btag>){2}<Btag>(.*?)</Btag>.*$','\4',1,1) as txt3
    21  from (
    22    select regexp_replace(x,'(>).(<)','\1\2',1,0,'n') as modx, x from t
    23  );
    X                              TXT1                 TXT2                                        TXT3
    <Atag>                         <Ctag>Tootsie</Ctag> <Ctag>Psycho</Ctag><Dtag>Casablanca</Dtag>  <Ctag>Goodfellas</Ctag><Dtag>Chinatown</Dtag>
    <Btag>
    <Ctag>Tootsie</Ctag>
    </Btag>
    <Btag>
    <Ctag>Psycho</Ctag>
    <Dtag>Casablanca</Dtag>
    </Btag>
    <Btag>
    <Ctag>Goodfellas</Ctag>
    <Dtag>Chinatown</Dtag>
    </Btag>
    </Atag>
    1 row selected.
    test@ora>
    test@ora>
    test@ora>@Keith - Regular expressions are from 10g upwards.
    isotope

  • Dbms_lob.instr searching backwards

    How can I use dbms_lob.instr to locate a string backward? such as "locate the position of the first 'xxx' before the current position (current pos == 88)?
    Thanks,
    Kevin

    SQL> set serveroutput on size 100000;
    SQL> DECLARE
      2    str   VARCHAR2(100) := 'aiiisalalkjsiiiksjjjslakjsljliiiljflakjfljsldiiiiiisfsljslkjdoooofdiiiiiisfsljslkjdoooof';
      3    pos   NUMBER;
      4    occur NUMBER := 1;
      5    subst VARCHAR2(3) := 'iii';
      6  BEGIN
      7    WHILE instr(str,
      8                subst,
      9                1,
    10                occur) > 0
    11    LOOP
    12      pos   := instr(str,
    13                     'iii',
    14                     1,
    15                     occur);
    16      occur := occur + 1;
    17    END LOOP;
    18    dbms_output.put_line('last occurrence of ' || subst ||
    19                         ' begins at position ' || pos);
    20  END;
    21  /
    last occurrence of iii begins at position 71
    PL/SQL procedure successfully completed
    Peter

  • InStr question

    When i use the InStr function, it return the first finding in the string.
    How can i find the last time it apper?
    wodi :=abc@cdf@fre@ytr;
    instr (wodi,'@')
    give me the first time.
    i use:
    instr(wodi,1,(length(wodi)-length(replace(wodi,'@','')))
    to find the last one.
    can i do it in more nice way??

    You can use 4 parameters for INSTR.
    instr(string, search_string, -1, 1)will give you last occurance because it starts searching from end.
    For an insight, see this.
    http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14200/functions068.htm
    Cheers
    Sarma.

  • Basic instr question (unclear orcale docs/fundamentals guide)

    Hi,
    i'm obviously quite new to this, but do understand the instr function more generally, its just the 'position' variable that's confusing me a bit, and both the oracle documentation and the fundamentals exam guide are quite vague on it.
    The INSTR(source string, search item, [start position],[nth occurrence of search
    item) function returns a number that represents the position in the source string,
    beginning from the given start position, where the nth occurrence of the search item
    begins
    ExamplesExample 7-127 Using Character Position to Search Forward to Find the Position of a Substring
    The following example searches the string "Corporate Floor", beginning with the third character, for the string "or". It returns the position in "Corporate Floor" at which the second occurrence of "or" begins.
    SHOW INSTR('Corporate Floor','or', 3, 2)
    14
    surely these two things are just untrue?
    if the search began from the given start position in the example taken from oracle docs, the answer would be 12, not 14? from character 3 ('r') to the second instance of 'or' is 12 characters inclusive, isn't it?
    or have i completely misunderstood?
    thanks,
    Nick
    Edited by: 967660 on 25-Oct-2012 06:55
    Edited by: 967660 on 25-Oct-2012 06:56

    Hi, Nick,
    967660 wrote:
    ... btw, why do the  tags not work?What are they supposed to do?
    If you want to post formatted text on this site in a fixed-width font, without compressing whitespace, then type these 6 characters:
    \(small letters only, inside curly brackets) before and after each section of formatted text.  This is great for query output as well as code samples.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Loop & Instr question

    Dear all,
    I have a string that will spool to a file from sql*plus, and the string maybe more than 255 characters, e.g.:
    v_sql := 'select surname, firstname, sex, birth,
    address1, address2,
    address3, ..., .... from employee;'
    dbms_output.put_line(v_sql);
    Now, I want to chop the string in several lines when 'meet' the comma ',' , the output I want become to, e.g.:
    dbms_output.put_line('select surname,');
    dbms_output.put_line('firstname,');
    dbms_output.put_line('sex,');
    dbms_output.put_line('... from employee;');
    So, I use the loop and instr in a procedure:
    procedure xxx (p_sql in varchar2) is
    v_len number := length(p_sql);
    v_comma number := 0;
    v_next_comma number := 0;
    v_string varchar2(1000);
    begin
    for v_cnt in 1..v_len loop
    if v_comma = 0 then
    v_comma := instr(p_sql, ',');
    v_string := substr(p_sql, 1, v_comma-1);
    dbms_output.put_line(v_string);
    else
    v_comma := instr(p_sql, ',');
    v_next_comma := instr(substr(p_sql, v_comma+1, v_len-v_comma), ',');
    v_string := substr(p_sql, v_comma+1, v_next_comma-1);
    dbms_output.put_line(v_string);
    end if;
    if v_comma > 0 and v_next_comma = 0 then
    v_cnt := v_comma +1; <--- v_cnt will not change
    elsif v_next_comma > 0 then
    v_cnt := v_next_comma +1;
    end if;
    end loop;
    end xxx;
    From the above coding, however, I found a problem that v_cnt will not skip to the 'comma' position. And I feel that it is not efficient if the length of the string is very long...
    So, is there another way to do? Please help. Thank you!
    Remarks: Database 10g.
    Regards.

    yes, it would see that you aren't running 10r2. here is the code you need
    http://www.oraclecommunity.net/group/sqlplus/forum/topic/show?id=1988559%3ATopic%3A9386
    the file - vsql.sql - is attached at the end. instead of using a cursor loop (curr_sql in my code) to get a statement, you'll just use your sql statement already in a variable. it's a simple procedure - breaks on certain keywords, or delimiters (like commas) before the linessize (132) is reached, and dbms_outputs the text.
    changing the end of script to use a static sql statement:
    begin
    my_stmt := 'MERGE /*+ dynamic_sampling(ST 4) dynamic_sampling_est_cdn(ST) */ INTO STATS_TARG'||
    'ET$ ST USING (SELECT STALENESS, OSIZE, OBJ#, TYPE#, CASE WHEN STALENESS > .5 THE'||
    'N 128 ELSE 0 END + AFLAGS AFLAGS, STATUS, SID, SERIAL#, PART#, BO# FROM ( SELECT'||
    ' /*+ no_expand dynamic_sampling(4) dynamic_sampling_est_cdn */ DECODE(BITAND(T.F'||
    'LAGS,16), 16, ROUND( LOG(0.01, NVL( LEAST( 100, GREATEST( 0.01, (DECODE(BITAND(M'||
    '.FLAGS, 1), 1, GREATEST(T.ROWCNT, M.INSERTS), LEAST((M.INSERTS + M.DELETES ';
    sql_frmt ( my_stmt, save_line, prefix );
             if (save_line is not null) then
                dbms_output.put_line( prefix || save_line );
                save_line := null;
             end if;
    end;
    MERGE /*+ dynamic_sampling ( ST 4 ) dynamic_sampling_est_cdn ( ST ) */ INTO STATS_TARGET$ ST USING (
    SELECT STALENESS, OSIZE, OBJ#, TYPE#, CASE WHEN STALENESS > .5 THEN 128 ELSE 0 END + AFLAGS AFLAGS, STATUS, SID, SERIAL#, PART#,
    BO#
    FROM (
    SELECT /*+ no_expand dynamic_sampling ( 4 ) dynamic_sampling_est_cdn */ DECODE ( BITAND ( T.FLAGS, 16 ), 16, ROUND ( LOG ( 0.01,
    NVL ( LEAST ( 100, GREATEST ( 0.01, ( DECODE ( BITAND ( M.FLAGS, 1 ), 1, GREATEST ( T.ROWCNT, M.INSERTS ), LEAST ( ( M.INSERTS
    + M.DELETES

  • Problem with DBMS_LOB.

    Hi, I am working with Oracle XE, I created a table with the following structure:
    CREATE TABLE "HR". EMPLOYEE_DOCUMENTS "
    "NUM_DOCUMENS" ENABLE NUMBER NOT NULL,
    "EMPLOYEE_COD" NUMBER (6.0) NOT NULL ENABLE,
    "TIPO_DOCUMENTO" VARCHAR2 (12 BYTE) NOT NULL ENABLE,
    "GENERADO_EL" DATE NOT NULL ENABLE,
    "DOCUMENTO_BLOB" BLOB,
    "DOCS8_CLOBS" CLOB,
    CONSTRAINT "EMPLOYEE_DOCUMENTS_PK" PRIMARY KEY ( "NUM_DOCUMENS")
    In the field CLOB stored as a text as follows:
    A person who carries the card. # for the use of the credential # pursued by the law.
    With DBMS_LOB, replacing the characters # content in the field CLOB by the value 1306958172, but the text that remains the last # concatenates and not get results like this:
    A person who carries the card. 1306958172 for the use of the credential 1306958172 pur
    One more question, as can assign field contents CLOb the type BLOB field to save as a Word document, an example please.
    Tahnk.
    Roberto.

    In that place of my Store Procedure:
    declare
    clobs1 CLOB;
    clobs2 CLOB;
    BLOBS blob;
    clobs_aux CLOB;
    valor number;
    cadena varchar2(4000);
    nposicion number;
    ncontar number:=1;
    begin
    select docs8_clobs, documento_blob into clobs1,blobs
    from hr.EMPLOYEE_DOCUMENTS
    where hr.EMPLOYEE_DOCUMENTS.NUM_DOCUMENS=12812;
    valor:=DBMS_LOB.INSTR(CLOBS1,'#',1,ncontar);
    clobs_aux:=clobs1;
    while valor<>0 loop
    nposicion:=valor+1;
    DBMS_OUTPUT.PUT_LINE(TO_CHAR(VALOR));
    clobs2:=DBMS_LOB.SUBSTR(clobs_aux,valor-1,1);
    clobs2:=clobs2||' '||to_clob('1306958172');
    clobs2:=clobs2||' '||DBMS_LOB.SUBSTR(clobs_aux,nposicion,nposicion);
    CLOBS_AUX:=CLOBS2;
    if ncontar>=1 then
    update hr.EMPLOYEE_DOCUMENTS
    set docs8_clobs=clobs_aux
    where num_documens=12812;
    commit;
    end if;
    --Recuperar campo CLOB actualizado.
    select docs8_clobs, documento_blob into clobs1,blobs
    from hr.EMPLOYEE_DOCUMENTS
    where hr.EMPLOYEE_DOCUMENTS.NUM_DOCUMENS=12812;
    CLOBS_AUX:=CLOBS1;
    valor:=DBMS_LOB.INSTR(CLOBS_AUX,'#',1,ncontar);
    ncontar:=ncontar+1;
    end loop;
    end;
    Roberto.

  • Using dbms_lob in trigger 10gR2

    Hello,
    I'm trying to read from a clob using dbms_lob in my trigger and assigning the value to a variable. My trigger is compiling fine, but it doesn't seem to be working.
    I'm using 10gR2. Am I misunderstanding how to read from/assign to a variable in a trigger?
    Line from trigger code:
    v_serial_start := dbms_lob.instr(:new.search_xml_clob,'serial=') + 8;
    Thanks,
    Mimi

    Here's a quick example that works fine for me....
    ME_XE?create table clobberin_tyme
      2  (
      3     some_column    number,
      4     variable_value number default 0,
      5     some_clob      clob default empty_clob()
      6  );
    Table created.
    Elapsed: 00:00:03.98
    ME_XE?
    ME_XE?
    ME_XE?create or replace trigger clobberin_tymeT01
      2  before insert or update on clobberin_tyme
      3  for each row
      4  declare
      5     v_serial_start    number;
      6  begin
      7
      8     v_serial_start       := dbms_lob.instr(:new.some_clob,'serial=') + 8;
      9
    10     :new.variable_value  := v_serial_start;
    11
    12  end;
    13  /
    Trigger created.
    Elapsed: 00:00:02.62
    ME_XE?
    ME_XE?
    ME_XE?insert into clobberin_tyme (some_column) values (1);
    1 row created.
    Elapsed: 00:00:00.31
    ME_XE?
    ME_XE?select * from clobberin_tyme;
           SOME_COLUMN     VARIABLE_VALUE SOME_CLOB
                     1                  8
    1 row selected.
    Elapsed: 00:00:00.17
    ME_XE?
    ME_XE?update clobberin_tyme
      2     set   some_column = 2,
      3           some_clob = 'hello world serial= coco puffs, i am cucu for them';
    1 row updated.
    Elapsed: 00:00:00.25
    ME_XE?
    ME_XE?select * from clobberin_tyme;
           SOME_COLUMN     VARIABLE_VALUE SOME_CLOB
                     2                 21 hello world serial= coco puffs, i am cucu for them
    1 row selected.
    Elapsed: 00:00:00.01

  • Dbms_lob wwv_flow_files

    I created a file upload as shown in the how-to, which I am using to upload csv files to the wwv_flow_files table. I would like to take the blob and break it apart for insert to a processing table. However, I am new to dbms_lob and would like any help possible. Are there any good references to using this in a pl/sql package to create inserts from blob fields?
    Many Thanks!!!

    Ok, I was able to find a solution and I'll post what I have. I was uploading a csv file with 3 fields (number, text, text) to the flow_files table. I was able to break this apart for insert using the anonymous block below. I'll probably store this as a function so that I can return a success/failure message.
    I hope this can help someone else!
    Begin
    Declare
    v_blob blob;                    
    v_raw raw(32767);     
    v_len number;
    v_pos integer := 1;
    v_amt binary_integer := 15;
    v_out varchar2(500);
    v_sql varchar2(255);
    v_search raw(4);
    l_linebreak varchar2(2) := chr(13)||chr(10);
    v_pad1 varchar2(5);
    v_pad2 varchar2(7);
    v_pad3 varchar2(5);
    begin
    v_sql := 'insert into table_x (field1,field2,field3) values ';
    v_search := utl_raw.cast_to_raw(l_linebreak);
    select BLOB_CONTENT
    into v_blob
    from WWV_FLOW_FILE_OBJECTS$
    where id = 775113501593078;
    v_pad1 := ','||'''';
    v_pad2 := ''''||','||'''';
    v_pad3 := ''''||')';
    v_pos := 1;
    loop
    v_amt := DBMS_LOB.INSTR(v_blob,v_search,v_pos);
    v_amt := v_amt - v_pos;
    If v_amt &lt; 1 then
    v_amt := 1;
    End if;
    /* Read current sector from blob into raw*/
    DBMS_LOB.READ(v_blob,v_amt,v_pos,v_raw);
    v_out := utl_raw.cast_to_varchar2(v_raw); --convert raw to varchar2 and set to output variable
    --dbms_output.put_line(v_out);
    v_out := replace(v_out,chr(10),'');
    v_out := replace(v_out,chr(13),'');
    If length(v_out) &gt; 0 then
    v_out := v_sql||'('||replace(substr(v_out,1,instr(v_out,',')),',',v_pad1)
    ||replace(substr(v_out,instr(v_out,',')+1,(length(v_out)-(instr(v_out,',')))),',',v_pad2)
                   ||v_pad3;
    --dbms_output.put_line(v_out);
         Execute immediate v_out;
    End if;
    v_out := null;
    v_raw := null;
    v_pos := v_pos + v_amt +1;
    v_amt := null;
    end loop;
    EXCEPTION
    WHEN others THEN
         dbms_output.put_line(sqlerrm);
    NULL;
    end;
    end;

  • DBMS_LOB IN ORACLE 8i TRIGGER

    Hello friends;
    I'm working with oracle 8i
    This is my TABLE
    CREATE TABLE PROBCLOB
    ( CAMPO1 CLOB,
    CAMPO2 NUMBER(1) );
    This is my TRIGGER
    CREATE OR REPLACE TRIGGER PROBANDO BEFORE INSERT ON PROBCLOB FOR EACH ROW
    DECLARE
    cCAMPO CLOB;
    nNUM NUMBER( 10 );
    BEGIN
    SELECT :NEW.CAMPO1 INTO cCAMPO FROM DUAL;
    SELECT DBMS_LOB.INSTR( cCAMPO, 'http' ) INTO nNUM FROM DUAL;
    IF nNUM <> 0 THEN
    :NEW.CAMPO2 := 0;
    END IF;
    END;
    When I try to insert in this table ( example: INSERT INTO PROBCLOB VALUES ( 'this is my web http:\\www.oracle.com', 1 ); )
    Then I have an error:
    ORA-22275: invalid LOB locator specified
    ¿Can I find the text "http" in my CLOB in a TRIGGER for change the value of CAMPO2?
    Thank you

    In oracle 10 this is OK

  • Dbms_lob-replace

    I have a clob database field and I want to replace every occurence of a char with another one(for ex. all 'a's to 'b's). There is not a repalce function in dbms_lob package and I want to know if there is a practical way of doing this.
    Thanks a lot.

    It's not ideal but as you're looking for chunks of text this is probably the only way.
    (1) Create a temporary LOB.
    (2) Use DBMS_LOB.INSTR() to find "dangeous HTML", however you define that.
    (3) Use DBMS_LOB.SUBSTR() and DBMS_LOB.WRITEAPPEND() to copy the safe HTML to the temporary lob.
    (4) Overwrite the CLOB with the temporary LOB.
    There may be smarter ways of doing this in 10g with regular expressions, but without knowing more about your scenario I wouldn't like to comment further.
    Cheers, APC

  • ?Working with clob and blob - using Dbms_Lob

    I need to search through a blob and remove some of the data, but having problems working with dbms_lob.erase.
    Reading the documentation, the procedure is supposed to work with either blobs or clobs, but I can't get it to work with the blob.
    Here's what I've coded and it does not work correctly for blobs.
    What have I've done wrong?
    declare
    v_start                   integer;
    v_stop                    integer;
    v_amount                  integer;
    v_max_len                  integer:=32676;
    v_offset                   integer:=1;
    v_new_length               integer;
    v_clob clob;
    v_blob blob;
    begin
    update test_clob
    set clob_id = clob_id
    where clob_id = 1
    returning clob_desc into v_clob;
    v_start := 0;
    v_stop  := 0;
    v_amount := 0;
    v_start := dbms_lob.instr(v_clob, '<property name="Name">SortMode', v_offset );
    v_stop  := dbms_lob.instr(v_clob, '</property>',  v_start );
    v_amount := ((v_stop - v_start)+11) ;
    dbms_output.put_line('Clob: '||v_clob);
    dbms_lob.erase(v_clob, v_amount, v_start);
    dbms_output.put_line('Clob: '||v_clob);
    rollback;
    update test_clob
    set clob_id = clob_id
    where clob_id = 1
    returning blob_desc into v_blob;
    v_start := 0;
    v_stop  := 0;
    v_amount := 0;
    v_start := dbms_lob.instr(v_blob, utl_raw.cast_to_raw('<property name="Name">SortMode'), v_offset );
    v_stop  := dbms_lob.instr(v_blob, utl_raw.cast_to_raw('</property>'),  v_start );
    v_amount := ((v_stop - v_start)+11) ;
    dbms_output.put_line('Blob: '||utl_raw.cast_to_varchar2(v_blob) );
    dbms_lob.erase(v_blob, v_amount, v_start);
    dbms_output.put_line('Blob: '||utl_raw.cast_to_varchar2(v_blob) );
    rollback;
    end trg_bui_user_assoc_layout;
    /This is the output
    Clob: this is only a test <property name="Name">SortMode</property>  should leave this alone
    Clob: this is only a test                                            should leave this alone
    Blob: this is only a test <property name="Name">SortMode</property>  should leave this alone
    Blob: this is only a test

    Well, you left out the table DDL and your insert for sample data (would be nice to have) as well as your Oracle version (pretty much a necessity).
    Since i had to make my own there could be a difference in how you populated your table, but i can't reproduce your findings.
    ME_ORCL?drop table test_clob purge;
    Table dropped.
    Elapsed: 00:00:00.09
    ME_ORCL?
    ME_ORCL?create table test_clob
      2  (
      3     clob_id     number not null primary key,
      4     clob_desc   clob,
      5     blob_desc   blob
      6  );
    Table created.
    Elapsed: 00:00:00.03
    ME_ORCL?
    ME_ORCL?insert into test_clob values
      2  (
      3        1
      4     ,  'this is only a test <property name="Name">SortMode</property>  should leave this alone'
      5     ,  utl_raw.cast_to_raw('this is only a test <property name="Name">SortMode</property>  should leave this alone')
      6  );
    1 row created.
    Elapsed: 00:00:00.01
    ME_ORCL?
    ME_ORCL?commit;
    Commit complete.
    Elapsed: 00:00:00.01
    ME_ORCL?
    ME_ORCL?declare
      2  v_start                   integer;
      3  v_stop                    integer;
      4  v_amount                  integer;
      5  v_max_len                  integer:=32676;
      6  v_offset                   integer:=1;
      7  v_new_length               integer;
      8
      9  v_clob clob;
    10  v_blob blob;
    11
    12  begin
    13
    14   update test_clob
    15   set clob_id = clob_id
    16   where clob_id = 1
    17   returning clob_desc into v_clob;
    18
    19   v_start := 0;
    20   v_stop  := 0;
    21   v_amount := 0;
    22
    23   v_start := dbms_lob.instr(v_clob, '<property name="Name">SortMode', v_offset );
    24   v_stop  := dbms_lob.instr(v_clob, '</property>',  v_start );
    25   v_amount := ((v_stop - v_start)+11) ;
    26
    27   dbms_output.put_line('Clob: '||v_clob);
    28
    29   dbms_lob.erase(v_clob, v_amount, v_start);
    30
    31   dbms_output.put_line('Clob: '||v_clob);
    32
    33   rollback;
    34
    35   update test_clob
    36   set clob_id = clob_id
    37   where clob_id = 1
    38   returning blob_desc into v_blob;
    39
    40   v_start := 0;
    41   v_stop  := 0;
    42   v_amount := 0;
    43
    44   v_start := dbms_lob.instr(v_blob, utl_raw.cast_to_raw('<property name="Name">SortMode'), v_offset );
    45   v_stop  := dbms_lob.instr(v_blob, utl_raw.cast_to_raw('</property>'),  v_start );
    46   v_amount := ((v_stop - v_start)+11) ;
    47
    48   dbms_output.put_line('Blob: '||utl_raw.cast_to_varchar2(v_blob) );
    49
    50   dbms_lob.erase(v_blob, v_amount, v_start);
    51
    52   dbms_output.put_line('Blob: '||utl_raw.cast_to_varchar2(v_blob) );
    53
    54   rollback;
    55
    56  end trg_bui_user_assoc_layout;
    57  /
    Clob: this is only a test <property name="Name">SortMode</property>  should leave this alone
    Clob: this is only a test                                            should leave this alone
    Blob: this is only a test <property name="Name">SortMode</property>  should leave this alone
    Blob: this is only a test                                            should leave this alone
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.03
    ME_ORCL?select *
      2  from v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
    PL/SQL Release 11.2.0.2.0 - Production
    CORE    11.2.0.2.0      Production
    TNS for Linux: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production
    5 rows selected.
    Elapsed: 00:00:00.03
    ME_ORCL?

  • File content retrive/view problem using DBMS_LOB...?

    Below this procedure working fine but getting buffer length/file content display problem...
    CREATE OR REPLACE Procedure READ_FILE_LOB_tmp IS
    l_dir CONSTANT VARCHAR2(30) := 'READ_LOB_DIR';
    l_fil CONSTANT VARCHAR2(30) := 'testfile.txt';
    l_sen CONSTANT RAW(100) := UTL_RAW.CAST_TO_RAW(CHR(10));
    l_loc BFILE;
    l_pos NUMBER := 1;
    l_sum BINARY_INTEGER := 0;
    l_buf VARCHAR2(400);
    l_end NUMBER;
    l_getlength NUMBER;
    l_ret BOOLEAN := FALSE;
    BEGIN
    l_loc := BFILENAME(l_dir, l_fil);
    l_getlength := DBMS_LOB.getlength(l_loc);
    l_ret := DBMS_LOB.FILEEXISTS(l_loc) = 1;
    IF (l_ret) THEN
    DBMS_LOB.OPEN(l_loc, DBMS_LOB.LOB_READONLY);
    LOOP
    l_end := DBMS_LOB.INSTR(l_loc, l_sen, l_pos, 1);
    IF l_end >= l_getlength THEN
    EXIT;
    END IF;
    l_sum := l_end - l_pos;
    DBMS_LOB.READ(l_loc, l_sum, l_pos, l_buf);
    dbms_output.put_line(UTL_RAW.CAST_TO_VARCHAR2(l_buf));
    l_pos := l_pos + l_sum + 1;
    END LOOP;
    DBMS_LOB.CLOSE(l_loc);
    END IF;
    END;
    My file content:
    Test Content1
    Test Content2
    Test Content3
    Test Content4
    Test Content5
    When i run this procedure, get the output like below format:
    Test Content1
    Test Content2
    Test Content3
    Test Content4
    Test Content5
    But I want to display as per file content format...

    I changed the code like...
    CREATE OR REPLACE Procedure READ_FILE_LOB IS
    l_dir CONSTANT VARCHAR2(30) := 'READ_LOB_DIR';
    l_fil CONSTANT VARCHAR2(30) := 'testfile.txt';
    l_seb CONSTANT RAW(100) := UTL_RAW.CAST_TO_RAW(CHR(32));
    l_sen CONSTANT RAW(100) := UTL_RAW.CAST_TO_RAW(CHR(10));
    l_loc BFILE;
    l_pos NUMBER := 1;
    l_sum BINARY_INTEGER := 0;
    l_buf VARCHAR2(4000);
    l_end NUMBER;
    l_ret BOOLEAN := FALSE;
    l_getlength NUMBER;
    BEGIN
    l_loc := BFILENAME(l_dir, l_fil);
    l_getlength := DBMS_LOB.getlength(l_loc);
    --dbms_output.put_line(l_getlength);
    If l_getlength > 0 then
    l_ret := DBMS_LOB.FILEEXISTS(l_loc) = 1;
    IF (l_ret) THEN
    DBMS_LOB.OPEN(l_loc, DBMS_LOB.LOB_READONLY);
    LOOP
    l_end := DBMS_LOB.INSTR(l_loc, l_sen, l_pos, 1);
    IF l_end = 0 THEN
    l_sum := l_getlength - l_pos + 1;
    DBMS_LOB.READ(l_loc, l_sum, l_pos, l_buf);
    dbms_output.put_line(UTL_RAW.CAST_TO_VARCHAR2(l_buf));
    EXIT;
    END IF;
    l_sum := l_end - l_pos;
    DBMS_LOB.READ(l_loc, l_sum, l_pos, l_buf);
    DBMS_LOB.TRIM(l_buf, (l_sum * 2) - 2);
    dbms_output.put_line(UTL_RAW.CAST_TO_VARCHAR2(l_buf));
    l_pos := l_pos + l_sum + 1;
    END LOOP;
    DBMS_LOB.CLOSE(l_loc);
    END IF;
    END IF;
    EXCEPTION
    WHEN OTHERS THEN
    dbms_output.put_line('Error:' || SQLERRM);
    DBMS_LOB.CLOSE(l_loc);
    END;
    Now its working fine with my format

Maybe you are looking for

  • Problem with links on email templates

    Problem with links on email templates Hi, We have been having issues with links on our email templates. Some of the links point to the following URL: http://server'sname/thirdparty/FCKeditor/editor/fckeditor.html?InstanceName=emailTemplatesDTO.htmlBo

  • Wrong input Witholding tax at AP Down Payment Invoice

    Dear all, My client has a problem. He already input AP Down Payment invoice and already has payment for it. Then when he want to draw AP Invoice from the Good Receipt PO, he found that the WTax Amount is wrong. It calculate as Total Amount - Down Pay

  • Thinkpad W500 and OpenSuse 11.1

    I installed OpenSuse 11.1 on W500. I am very impressive. What works out of the box:     X-windows (I use Intel driver)     Microphone     Webcam     Trackpoint and trackpad     Bluetooth     Wireless (it identified my card as 5100 rather than 5300, b

  • Healing Brush/Clone Tools Frustration

    I am having an impossible time trying to effect this change in a product shot. Please see Before/After photo attached. I cannot remove the label text on the left and right side of the jar without smearing the edges. I'm using the Healing Brush and th

  • PSE 6 - Reconnect Missing Files... None there!

    When I click on Reconnect All Missing Files, after a few moments the "Searching for missing file" box shows up and I click on Browse. In the next box that appears, there's supposed to be a list of all of the missing files but my problem is that there