Dbms_lob.erase

Hi all
I am using dbms_lob.erase to delete part of data in my Clob
My question is does dbms_lob.erase also free up the space allocated by previous content of my clob?
If not is there someway to do it? After .erase i want to populate clob with different set of data and the amount of data is bigget than existing size of clob
Thanks for all your help

Galia,
I hope this example illustrates your question
completely:
SQL> declare
  2   clb clob;
  3   orig varchar2(10) := '1234567890';
  4   adds varchar2(3) := '456';
  5   amnt number := 3;
  6  begin
  7 
  8   dbms_lob.createtemporary(clb,true);
  9   dbms_lob.write(clb,10,1,orig);
10   dbms_output.put_line('Original content: ' || clb);
11   dbms_lob.erase(clb,amnt,4);
12   dbms_output.put_line('After-erase content: ' || clb);
13   dbms_lob.writeappend(clb,3,adds);
14   dbms_output.put_line('After-writeappend content: ' || clb);
15   dbms_lob.write(clb,3,4,adds);
16   dbms_output.put_line('After-write content: ' || clb);
17   amnt := dbms_lob.getlength(clb);
18   dbms_lob.erase(clb,amnt);
19   dbms_output.put_line('After-complete erase content: ' || clb);
20   dbms_lob.write(clb,20,1,orig || orig);
21   dbms_output.put_line('New content: ' || clb);
22  end;
23  /
Original content: 1234567890
After-erase content: 123   7890
After-writeappend content: 123   7890456
After-write content: 1234567890456
After-complete erase content:
New content: 12345678901234567890
&nbsp
PL/SQL procedure successfully completed.Rgds.

Similar Messages

  • [ 10g ] How to make dbms_lob.erase trim fragment away?

    Hello!
    I'm trying to remove some parts of CLOB with DBMS_LOB.ERASE, and it obviously just replaces fragment with spaces. This behaviour is stated in manual, but the fact is I need to actually REMOVE this fragment. More to that, I also need to insert some data in the middle of the CLOB. Of which, obviously, DBMS_LOB.WRITE isn't capable to do.
    I've googled that 11g has some vague new functions DBMS_LOB.FRAGMENT_DELETE and DBMS_LOB.FRAGMENT_INSERT, doing what I need. But I'm on 10g. So, is there way to do what I need without tedious blob copying/trimming?

    I've written rough replacements for dbms_lob.fragment_delete and dbms_lob.fragment_insert. Be glad for any advise.
    procedure clob_fragment_delete(l_clob in out clob, l_amount in integer, l_offset in integer)
    is
      l_len integer := dbms_lob.getlength(l_clob);
    begin
      dbms_lob.copy(l_clob, l_clob, l_len - l_offset - l_amount, l_offset, l_offset + l_amount);
      dbms_lob.trim(l_clob, l_len - l_amount);
    end;
    procedure clob_fragment_insert(l_clob in out clob, l_amount in integer, l_offset in integer,
                                   l_buffer in varchar2 character set l_clob%charset)
    is
      l_len integer := dbms_lob.getlength(l_clob);
    begin
      dbms_lob.copy(l_clob, l_clob, l_len - l_offset, l_offset + l_amount, l_offset);
      dbms_lob.write(l_clob, l_amount, l_offset, l_buffer);
    end;

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

  • XML,CLOB  AND MEMORY : CONSUMED BUT NOT RELEASED !!!

    Hi,
    I'm working with XMLGEN Package and XSLT Processor to produce XML Document on Oracle 8.1.7.3 server, I use 9i XML and Java packages.
    I'm facing the following BIG MEMORY problem :
    Environment : I must generate an XML parsed with an XSL document of 80Mo (nearly 22 000 rows),
    as XMLGEN is on DOM parsing method, I extract my XML by 500 Rows and I loop until 22 000 rows. I use DBMS_JOB with jobs who read and execute export each minute.
    The algorithme is :
    keeprow=22000
    while keeprow>0
    Create 3 clob (DBMS_LOB Package) : one for XSL Sheet, one for XML and one for result
    GetXML (XMLGEN Package)
    Transform in XSL (XSL Processor)
    Write to disk (UTL_FILE Package)
    Free the 3 Clob ((DBMS_LOB Package))
    keeprow =keeprow-500
    loop
    The problem : The process start at 250Mo ot total memory and END at 1000 Mo of used memory and NEVER RELEASE 1 ko of memory.
    So often I get a JavaOutOfMemoryError (I've allocated 1Go Ram to my JAVA process).
    Any help will be very very appreciated !
    My derived problem is 22 000 rows is not enough I've some export of 200 000 rows to do (And I cannot allocate 10 Go of RAM !!!)
    Following My PL/SQL Code.
    Regards
    Fred
         PROCEDURE DO_EXPORT_XML(
                   P_JOB_ID JOB_PARAMETRE.JOB_ID%TYPE,
                   P_JOB_ID_ORDRE JOB_PARAMETRE.JOB_ID_ORDRE%TYPE,
                   P_CLE_UP UPLOADREQ_TEMP.ID%TYPE,
                   P_LOAD_OR_DELOAD VARCHAR2)
              IS
              L_FILE_NAME JOB_PARAMETRE.JOB_FILE_NAME_DEST%TYPE;
              L_REP_NAME JOB_PARAMETRE.JOB_REP_NAME_DEST%TYPE;
              L_FILE_STYLESHEET JOB_PARAMETRE.JOB_STYLESHEET%TYPE;
              L_VERSION_PDM JOB_PARAMETRE.JOB_VPDM%TYPE;
              P_SELECT varchar2(4000):='';
              P_CURSOR varchar2(4000):='';
         l_filehandler_out UTL_FILE.FILE_TYPE;
              --Variable pour le traitement par lot de 500
              L_NBROW_TODO_ATONCE number := 500;
              L_NBROW_MIN number := 1;
              L_NBROW_MAX number := -1;
              L_NBROWKEEPTODO number := -1;
              xslString CLOB := null;
              res number default -1;
              xmlString CLOB := null;
              li_ret number := 0;
              li_faitle number := 0;
              amount integer:= 255;
              li_loop integer := 0;
              charString varchar2(255);
              ls_deload varchar2(255) default '';
              ls_SQL varchar2(4000) default '';
              ls_temp_file varchar2(255) default '';
              text_file_dir varchar2(32) := 'e:\temporarydir';
              l_par xmlparser.parser;
         l_xml xmldom.domdocument;
         l_pro xslprocessor.processor;
         l_xsl xslprocessor.stylesheet;
              docfragnode xmldom.DOMNode;
              docfrag xmldom.DOMDocumentFragment;
              l_parsedclob clob := null;
              l_amount binary_integer := 32767;
              l_ligne varchar2(32767);
              l_offset number default 1;
              l_pos number default null;
              l_pos2 number default null;
              l_lobsize number default null;
              l_memsize number default 1073741824; --1024 Mo
              l_mempipo number default 0;
              type rc is ref cursor;
              l_cursor rc;
              cursor TEMPLATE is select UNSPSC,1 as NB from UPLOADREQ_TEMP where 1=2;
              c1rec TEMPLATE%rowtype;          
              BEGIN
              l_mempipo:=setmaxmemorysize(l_memsize);
              dbms_lob.createtemporary(l_parsedclob, true, dbms_lob.session);
              dbms_lob.createtemporary(xmlstring, true, dbms_lob.session);
              --return the good select
              GET_SELECT_TO_EXPORT_XML(P_JOB_ID , P_JOB_ID_ORDRE , P_CLE_UP , P_SELECT,P_CURSOR, P_LOAD_OR_DELOAD);
                        SELECT JOB_FILE_NAME_DEST,JOB_REP_NAME_DEST,JOB_STYLESHEET
                        INTO L_FILE_NAME,L_REP_NAME,L_FILE_STYLESHEET
                        FROM JOB_PARAMETRE
                        WHERE JOB_ID =P_JOB_ID AND JOB_ID_ORDRE=P_JOB_ID_ORDRE;
                        l_filehandler_out := UTL_FILE.FOPEN(text_file_dir, L_FILE_NAME, 'w',l_amount);
                        --Return XSL Sheet in a clob : cause of memory consumed  but not released
                   xslString := METACAT.load_a_file( 1,L_FILE_STYLESHEET);     
                        open l_cursor for P_CURSOR;
    LOOP
                   fetch l_cursor into c1rec;
                   exit when l_cursor%notfound;
                             L_NBROW_MIN := 1;
                             L_NBROW_MAX := 0;
                             L_NBROWKEEPTODO:=c1rec.NB;
                             LOOP
                             begin
                                  if(L_NBROWKEEPTODO > L_NBROW_TODO_ATONCE) THEN
                                       begin
                                       L_NBROW_MAX:= L_NBROW_TODO_ATONCE + L_NBROW_MAX;
                                       L_NBROWKEEPTODO:= L_NBROWKEEPTODO - L_NBROW_TODO_ATONCE;
                                       end;
                                  else
                                       begin
                                       L_NBROW_MAX:= L_NBROW_MAX + L_NBROWKEEPTODO;
                                       L_NBROWKEEPTODO:=0;
                                       end;
                                  end if;
                                  --on ouvre le fichier de risultats
                                  ls_SQL:= P_SELECT || ' AND ( ROWNUM BETWEEN ' || L_NBROW_MIN || ' AND ' || L_NBROW_MAX || ' ) and UNSPSC=''' || c1rec.UNSPSC || '''';
                                  ls_temp_file := c1rec.UNSPSC || '_' || L_FILE_NAME;
                                  L_NBROW_MIN:=L_NBROW_TODO_ATONCE + L_NBROW_MIN;
                                  --CAT_AUTOLOAD.JOB_ADD_TRACE (P_JOB_ID,'UPLOAD REQUISITE : Export donnies REQUETE ' || to_char(li_loop), ls_SQL,'',0,0);
                                  xmlgen.resetOptions;
                                  xmlgen.setErrorTag('ERROR_RESULT');
                                  xmlgen.setRowIdAttrName('NAH');
                                  xmlgen.setRowIdColumn('NAH');
                                  xmlgen.setEncodingTag('ISO-8859-1');
                                  xmlgen.useNullAttributeIndicator(false);
                                  if(xmlString is not null) then
                                       dbms_lob.open(xmlString,dbms_lob.lob_readwrite);
                                       l_lobsize:= dbms_lob.Getlength(xmlString);
                                       if(l_lobsize>0) then
                                       dbms_lob.erase(xmlString,l_lobsize,1);
                                       end if;
                                       dbms_lob.close(xmlString);
                                  dbms_lob.freetemporary(xmlString);
                                       dbms_lob.createtemporary(xmlstring, true, dbms_lob.session);
                                  end if;
    --Return XML in a clob : cause of memory consumed  but not released
                                  xmlString := xmlgen.getXML(ls_SQL,0);
                                  l_par := xmlparser.newparser;
                                  xmlparser.parseclob(l_par, xslString);
                                  l_xsl := xslprocessor.newstylesheet(xmlparser.getdocument(l_par),null);
                                  xmlparser.parseclob(l_par, xmlString);
                                  l_xml := xmlparser.getdocument(l_par);
                                  l_pro := xslprocessor.newprocessor;
                                       xslprocessor.showWarnings(l_pro, true);
                                       xslprocessor.setErrorLog(l_pro, text_file_dir || substr(ls_temp_file,0,length(ls_temp_file)-4) || '_logerreur.XML');
                                       if(l_parsedclob is not null) then
                                                 dbms_lob.open(l_parsedclob,dbms_lob.lob_readwrite);
                                                 l_lobsize:= dbms_lob.Getlength(l_parsedclob);
                                                 if(l_lobsize>0) then
                                                 dbms_lob.erase(l_parsedclob,l_lobsize,1);
                                                 end if;
                                                 dbms_lob.close(l_parsedclob);
                                            dbms_lob.freetemporary(l_parsedclob);
                                                 dbms_lob.createtemporary(l_parsedclob, true, dbms_lob.session);
                                       end if;
                        --Return XML Processed with XSL in a clob : cause of memory consumed  but not released
                                  xslprocessor.processxsl(l_pro,l_xsl,l_xml,l_parsedclob);
                                       --release NOTHING
                                  xmlparser.freeparser(l_par);
                                  xslprocessor.freeprocessor(l_pro);
                                                      l_ligne:='';
                                                      l_offset :=1;
                                                      l_pos := null;
                                                      l_pos2 := null;
                                                      if(li_loop=0) then
                                                           begin
                                                                --on ouvre le fichier et on sauve l'entete + les donnies dedans.
                                                                     l_pos:=dbms_lob.instr(l_parsedclob,'</DATA>');
                                                      if ( nvl(l_pos,0) > 0 ) then
                                                                          loop
                                                                          if(l_pos-1>l_amount + l_offset ) then
                                                                                    l_ligne:=dbms_lob.SUBSTR(l_parsedclob,l_amount,l_offset);
                                                                                    UTL_FILE.PUT(l_filehandler_out,l_ligne);
                                                                                    UTL_FILE.fflush(l_filehandler_out);
                                                                                    l_offset:=l_offset+l_amount;
                                                                               else
                                                                                    l_ligne:=dbms_lob.SUBSTR(l_parsedclob,l_pos-1 -l_offset ,l_offset);
                                                                                    UTL_FILE.PUT(l_filehandler_out,l_ligne);
                                                                                    UTL_FILE.fflush(l_filehandler_out);
                                                                                    exit;
                                                                               end if;
                                                                          end loop;
                                                                     else
                                                                          EXIT;
                                                                     end if;
                                                           end;
                                                      else
                                                           --on met les donnies donc on ne repete pas le debut
                                                           begin
                                                                     l_pos:=dbms_lob.instr(l_parsedclob,'<ITEM');
                                                      if ( nvl(l_pos,0) > 0 ) then
                                                                     l_pos2:=dbms_lob.instr(l_parsedclob,'</DATA>');
                                                      if ( nvl(l_pos2,0) > 0 ) then
                                                                          loop
                                                                          if(l_pos + l_amount <= l_pos2 -1 ) then
                                                                                    l_ligne:=dbms_lob.SUBSTR(l_parsedclob,l_amount,l_pos);
                                                                                    UTL_FILE.PUT(l_filehandler_out,l_ligne);
                                                                                    UTL_FILE.fflush(l_filehandler_out);
                                                                                    l_pos:=l_pos +l_amount;
                                                                               else
                                                                                    l_ligne:=dbms_lob.SUBSTR(l_parsedclob,l_pos2 -1 -l_pos,l_pos);
                                                                                    UTL_FILE.PUT(l_filehandler_out,l_ligne);
                                                                                    UTL_FILE.fflush(l_filehandler_out);
                                                                                    exit;
                                                                               end if;
                                                                          end loop;
                                                                          else
                                                                          exit;                                                                      
                                                                          end if;
                                                                     end if;
                                                           end;
                                                      end if;
                                                 li_loop:=li_loop + 1 ;
                                                 --UTL_FILE.FCLOSE(l_filehandler_in);
                                                 JAVA_GC();
                                                 EXIT WHEN L_NBROWKEEPTODO=0;
                                                 Exception
                                                 when others then
                                                      begin
                                                      -- IF(utl_file.is_open(l_filehandler_in)) THEN
                                                      --               utl_file.fclose( l_filehandler_in);
                                                      -- END IF;
                                                      IF(utl_file.is_open(l_filehandler_out)) THEN
                                                                     utl_file.fclose( l_filehandler_out);
                                                      END IF;
                                                      RAISE_APPLICATION_ERROR(-20001,'File with errors');
                                                      end;
                             END;
                             END LOOP;
    END LOOP;
    CLOSE l_cursor;
                        if ( xmlString is not null ) then
                                  dbms_lob.open(xmlString,dbms_lob.lob_readwrite);
                                  l_lobsize:= dbms_lob.Getlength(xmlString);
                                  if(l_lobsize>0) then
                                  dbms_lob.erase(xmlString,l_lobsize,1);
                                  end if;
                                  dbms_lob.close(xmlString);
                                  dbms_lob.freeTemporary( xmlString);
                        end if;
                        if(l_parsedclob is not null) then
                                  dbms_lob.open(l_parsedclob,dbms_lob.lob_readwrite);
                                  l_lobsize:= dbms_lob.Getlength(l_parsedclob);
                                  if(l_lobsize>0) then
                                       dbms_lob.erase(l_parsedclob,l_lobsize,1);
                                  end if;
                                  dbms_lob.close(l_parsedclob);
                                  dbms_lob.freetemporary(l_parsedclob);
                        end if;
                        UTL_FILE.NEW_LINE(l_filehandler_out);
                        l_ligne:='</DATA></CATALOG>';
                        UTL_FILE.PUT(l_filehandler_out,l_ligne);
                        UTL_FILE.FCLOSE(l_filehandler_out);                    
                   EXCEPTION
                   when others then
                             begin
                             IF(utl_file.is_open(l_filehandler_out)) THEN
                                       utl_file.fclose( l_filehandler_out);
                                  END IF;
                             end;     
              END;
    ******************************

    Thank you for the info - I had no idea I was puing myself in danger by cutting it so close.  Since your post I have moved my iphoto library to an external drive and now have 165 GB of space on my HD.  Following this I have 2 questions.
    1.  Since my available HD space was reduced by the size of the photo download it seems logical that the download is somewhere on my HD still.  Is there a place where these photos might be hiding on my HD even though they are not available on the iphoto library?
    2.  I was able to recover the .jpg files which are fine.  I also recovered the .mov files but they have been compromised.  I am hoping I can find the originals still on the HD somewhere.  If not, do you have any suggestions for recovery methods or programs?  I have not used the SD card since the incident so I should be able to attempt another recovery to salvage the .mov files if there is an alternative method/program available.
    Thanks again!

  • ORA-04091: table OBJ_SIGN_TRANS is mutating, trigger/function may not..

    Hi ,
    I m getting table mutating error while trying to update this table, i m doing transaction signing from Java mehtod, table has 2 triggers, whlie updating this table i m facing error. Triggers are mentioned bellow including a package which i m using global variables and table description too.
    CREATE OR REPLACE PACKAGE pck$mutations
    IS
    Gv_ref_id varchar2(50);
    Gv_line_no number;
    Gv_ref_ser varchar2(6);
    Gv_sign_Status char(1);
    END pck$mutations;
    CREATE OR REPLACE TRIGGER trig_obj_sign_Trans
    BEFORE UPDATE ON obj_sign_trans
    FOR EACH ROW
    BEGIN
    Pck$mutations.Gv_ref_id :=:NEW.ref_id;
    Pck$mutations.Gv_ref_ser :=:NEW.ref_ser;
    Pck$mutations.Gv_line_no :=:NEW.line_no;
    Pck$mutations.Gv_sign_status :=:NEW.sign_status;
    END;
    CREATE OR REPLACE TRIGGER aft_obj_sign_Trans
    AFTER UPDATE ON OBJ_SIGN_TRANS
    DECLARE
    CURSOR c_ref_id
    IS SELECT line_no,ref_id
    FROM obj_sign_trans
    WHERE ref_ser= RTRIM(pck$mutations.Gv_ref_ser)
              AND ref_id = pck$mutations.Gv_ref_id
              AND LINE_NO <>pck$mutations.Gv_LINE_NO;
    dest_lob BLOB;
    src_lob BLOB;
              dest_lob_len number(14,3);
              src_lob_len number(14,3);
    BEGIN
    For i in c_ref_id
    loop
              SELECT trans_info ,dbms_lob.getlength(trans_info)
                   INTO src_lob,src_lob_len
              FROM OBJ_SIGN_tRANS
              WHERE REF_ID=pck$mutations.Gv_ref_id
                   AND REF_SER=RTRIM(pck$mutations.Gv_ref_ser)
                   AND LINE_NO=pck$mutations.Gv_line_no;
              DBMS_OUTPUT.PUT_LINE(TO_CHAR(src_lob_len ));
              DBMS_OUTPUT.PUT_LINE(pck$mutations.Gv_line_no);
              DBMS_OUTPUT.PUT_LINE('SELECTED SOURCE ...............');
    -- EXIT WHEN c_ref_id%NOTFOUND;
              SELECT trans_info,dbms_lob.getlength(trans_info)
                   INTO dest_loB,dest_lob_len
              FROM OBJ_SIGN_tRANS
              WHERE REF_ID=pck$mutations.Gv_ref_id
                   AND REF_SER=RTRIM(pck$mutations.Gv_ref_ser)
              AND LINE_NO =I.LINE_NO FOR UPDATE;
              DBMS_OUTPUT.PUT_LINE(TO_CHAR(dest_lob_len) );
                   DBMS_LOB.ERASE(dest_lob,dest_lob_len,1);
                   DBMS_LOB.WRITE(dest_lob,src_lob_len,1,src_lob);
                   DBMS_OUTPUT.PUT_LINE(I.LINE_NO );
              DBMS_OUTPUT.PUT_LINE(pck$mutations.Gv_ref_id );
              DBMS_OUTPUT.PUT_LINE('UPDATED...............');
              end loop ;
         END;
    SQL> desc obj_sign_trans
    Name Null? Type
    REF_SER NOT NULL VARCHAR2(6)
    REF_ID NOT NULL VARCHAR2(50)
    LINE_NO NOT NULL NUMBER(3)
    SIGN_FOR VARCHAR2(100)
    ROLE_CODE__SIGN VARCHAR2(10)
    SIGN_DATE DATE
    USER_ID__SIGN VARCHAR2(10)
    SIGN_REMARKS VARCHAR2(100)
    CERT_NO VARCHAR2(200)
    SIGN_STATUS CHAR(1)
    TITLE VARCHAR2(50)
    EMP_CODE CHAR(10)
    CREATE_DATE DATE
    TRANS_INFO BLOB
    ROLE_TYPE VARCHAR2(1)
    ROLE_ENTITY VARCHAR2(1)
    ENTITY_CODE CHAR(10)
    PRC_INST__WF VARCHAR2(50)
    can anyone help me with this regard.
    your prompt help would be appriciated.
    regards
    qamar

    Please see the below
    How to solve mutating error
    cheers

  • Undo segment recovery wait

    Hi All;
    In an 10gR2 physical standby dataguard environment, i open standby db READ-ONLY for extraction. After a performance issue we've seen "undo segment recovery" wait events on database.
    The definition of "undo segment recovery" wait event:
    +"PMON is rolling back a dead transaction. The wait continues until rollback finishes."+
    Because this is a READ-ONLY db, isn't it strange to wait for rollback operation?
    Thanks
    Emre

    Hi,
    Apart from this most of the other things you should be able to do.
    INSERT = change was caused by an insert statement
    UPDATE = change was caused by an update statement
    DELETE = change was caused by a delete statement
    DDL = change was caused by a DDL statement
    START = change was caused by the start of a transaction
    COMMIT = change was caused by the commit of a transaction
    ROLLBACK = change was caused by a full rollback of a transaction
    LOB_WRITE = change was caused by an invocation of DBMS_LOB.WRITE
    LOB_TRIM = change was caused by an invocation of DBMS_LOB.TRIM
    LOB_ERASE = change was caused by an invocation of DBMS_LOB.ERASE
    SELECT_FOR_UPDATE = operation was a SELECT FOR UPDATE statement
    SEL_LOB_LOCATOR = operation was a SELECT statement that returns a LOB locatorAm not sure why you would be interested to know what you other features(except from reading) you would like to do on read-only database.
    Regards
    Anurag

  • Strip strings from LOB

    I am trying to strip out a string that appears multiple times in a lob field. I think I have the code, but it seems to be skipping every other occurrence, and I must be missing something silly, but need some help - this is on a 10g XE database.
    create table t (num number, xml clob);
    declare
    l_xml1 clob;
    l_xml2 clob;
    l_sql varchar2(4000);
    l_ctx sys.dbms_xmlgen.ctxHandle ;
    l_pattern varchar2(4000) := '<?xml version="1.0"?>';
    l_start_loc integer := 1;
    l_offset integer := 1;
    l_substr varchar2(4000);
    l_nth integer := 1;
    l_len number;
    begin
    dbms_output.put_line('Begin');
    l_sql := 'select sysdate, 1 from dual';
    l_ctx := sys.dbms_xmlgen.newContext(queryString => l_sql);
    l_xml1 := sys.dbms_xmlgen.getXML(ctx => l_ctx);
    sys.dbms_xmlgen.closeContext(l_ctx);
    l_sql := 'select sysdate, 2 from dual';
    l_ctx := sys.dbms_xmlgen.newContext(queryString => l_sql);
    l_xml2 := sys.dbms_xmlgen.getXML(ctx => l_ctx);
    sys.dbms_xmlgen.closeContext(l_ctx);
    dbms_lob.append(src_lob => l_xml2, dest_lob =>l_xml1);
    l_sql := 'select sysdate, 3 from dual';
    l_ctx := sys.dbms_xmlgen.newContext(queryString => l_sql);
    l_xml2 := sys.dbms_xmlgen.getXML(ctx => l_ctx);
    sys.dbms_xmlgen.closeContext(l_ctx);
    dbms_lob.append(src_lob => l_xml2, dest_lob =>l_xml1);
    l_sql := 'select sysdate, 4 from dual';
    l_ctx := sys.dbms_xmlgen.newContext(queryString => l_sql);
    l_xml2 := sys.dbms_xmlgen.getXML(ctx => l_ctx);
    sys.dbms_xmlgen.closeContext(l_ctx);
    dbms_lob.append(src_lob => l_xml2, dest_lob =>l_xml1);
    l_sql := 'select sysdate, 5 from dual';
    l_ctx := sys.dbms_xmlgen.newContext(queryString => l_sql);
    l_xml2 := sys.dbms_xmlgen.getXML(ctx => l_ctx);
    sys.dbms_xmlgen.closeContext(l_ctx);
    dbms_lob.append(src_lob => l_xml2, dest_lob =>l_xml1);
    insert into t (num, xml) values (1, l_xml1);
    l_len := length(l_pattern);
    dbms_output.put_line('l_len: '||l_len);
    while l_start_loc <> 0
    loop
    dbms_output.put_line('l_nth: '||l_nth);
    l_start_loc := dbms_lob.instr(lob_loc => l_xml1,
    pattern => l_pattern,
    offset => l_offset,
    nth => l_nth);
    dbms_output.put_line('Start location: '||l_start_loc);
    if l_start_loc <> 0 then
    dbms_lob.erase(lob_loc => l_xml1, amount => l_len, offset => l_start_loc);
    dbms_output.put_line('String deleted');
    end if;
    l_nth := l_nth + 1;
    end loop;
    insert into t (num, xml) values (2, l_xml1);
    commit;
    dbms_output.put_line('End');
    end;
    If you look at the 2 rows inserted into the table, it appears only every other string was removed, and I can't figure out why.
    Thanks in advance

    Well, your code's a bit hard to read but it looks like you are:
    - Reading the nth occurrence of the string, with n = 1
    - Erasing this occurrence of the string
    - Reading the nth occurrence of the string in the remaining lob, with n = 2
    - Erasing this occurrence of the string
    So you will be reading the 1st, 3rd, 6th, ..., n(n+1)/2 th occurrences.
    cheers,
    Anthony

  • Enqueue and Dequeue of BLOB messages

    Hi all,
    Does anyone have any experience with enqueue and dequeue of BLOB messages? I have PDF files that I would like to send via aq. I can enqueue them, but not dequeue them. When I attempt to deque, I get the following error:
    ORA-25236: buffer too small for user data
    Here is my enqueue code:
    set serveroutput on size 1000000
    set timing on
    /* Enqueue to msg_queue: */
    DECLARE
       Enqueue_options     DBMS_AQ.enqueue_options_t;
       Message_properties  DBMS_AQ.message_properties_t;
       Message_handle      RAW(16);
       Message             blob;
         TmpMsg              blob := empty_blob;
         cnt                 number;
    BEGIN
       DBMS_AQ.ENQUEUE(queue_name => 'JOOSTENBERGVLAKTE',
       Enqueue_options            => enqueue_options,
       Message_properties         => message_properties,
       Payload                    => tmpmsg,
       Msgid                      => message_handle);
         select t.user_data into message from test_queue t where t.msgid = message_handle;
         select blob_content into tmpmsg from tbl;
         cnt := length(message) + 1;
         dbms_lob.erase(message, cnt);
         dbms_lob.trim(message, 0);
         dbms_lob.append(message, tmpmsg);
         dbms_output.put_line('Erased ' || cnt || ' characters');
         dbms_output.put_line('Message length ' || length(message));
       COMMIT;
    END;
    /And here is my deque code:
    set serveroutput on 1000000;
    declare
         l_options         dbms_aq.dequeue_options_t;
         l_properties      dbms_aq.message_properties_t;
         l_hnd             RAW(16);
         l_msg             blob := empty_blob;
    begin
         dbms_aq.dequeue(
              queue_name => 'JOOSTENBERGVLAKTE',
              dequeue_options => l_options,
              message_properties => l_properties,
              payload => l_msg,
              msgid => l_hnd
         commit;
    exception
         when others then
              rollback;
              raise;
    end;
    /

    Hi,
    I think you have the order of enqueueing and filling your blob in the wrong order. I understand why you do it, because inserting a blob in the table you could do that in this way. But I think that you should fill and close your blob before enqueueing it.
    Try something like:
    l_attachment blob;-- := :p_attachment;
    begin
    dbms_lob.createtemporary(l_attachment, false);
    dbms_lob.write( lob_loc => l_attachment
    , amount => length(:p_attachment)
    , offset => 1
    , buffer => utl_raw.cast_to_raw(:p_attachment));
    Another small remark is that I see you doing a commit right after the enqueue-dequeue. In your enqueu example it seems to make sense because you try to fill the blob afterwards. But you could also use the enqueue-dequeue option "visibility" and set that on dbms_aq.immediate. Then you don't have to do a commit. This is handy for enqueueing messages with out affecting your transaction.
    Regards,
    Martien

  • Delete BLOB image without deleting associated row?

    We have some BLOB data stored out of line. The rows associated with it have been set to NULL, but the image files remain and are filling the tablespace. Is there any way of getting rid of the images without deleting their associated rows?
    We have also tried DBMS_LOB.ERASE without success.
    Thanks.

    Hi Liz,
    You can't delete a cell, but you can move the cells below it up. Select all cells below that cell in that column. Either drag the selected cells up, or Edit > Cut then Paste onto the cell you want to remove. What this does is move the cells' contents.
    To "remove" A2,
    There is now a blank cell at the bottom. This has also moved the cell borders.
    Regards,
    Ian.

  • Edit CLOB value

    Hi all!
    I'm sure this is something simple, but I just can't seem to get it and have been beating my head against a wall for several days...Help! :)
    I have a clob that contains the following:
    <?xml version="1.0"?>
    <PARMS>
    <P_BOOK_TYPE_CODE>ASSETS INTERNAL</P_BOOK_TYPE_CODE>
    <P_STATE>SD</P_STATE>
    <P_BEG_DATE_EFFECTIVE>01-JAN-1990</P_BEG_DATE_EFFECTIVE>
    <P_END_DATE_EFFECTIVE>31-DEC-2007</P_END_DATE_EFFECTIVE>
    </PARMS>
    I want to remove the first part of it
    '<?xml version="1.0"?>'
    How do I code this? I've been trying with dbms_lob.WRITE but I just can't seem to find the right parameter values...
    Thanks!!
    Janel

    Hi,
    Have you tried dbms_lob.erase ?
    PROCEDURE DBMS_LOB.ERASE
    (lob_loc IN OUT CLOB CHARACTER SET ANY_CS,
    amount IN OUT INTEGER,
    offset IN INTEGER := 1);
    regards
    Gokhan

  • How do you recover the contents of a document once its been erased

    Hi Pages community
    Any idea how to recover the contents of a document once the contents has been erased but the document still exists?
    I already reset the Ipad using an Icloud backup from June 11th.
    Thanks
    Beth

    This is modified code. I think it works.
    declare
    a blob;
    b blob;
    d number:=1;
    e number:=1;
    f number:=1;
    begin
    select module_floorplan into a from tblob where seqno = 100;
    select module_floorplan into b from tblob where seqno = 100;
    e:=length(a);
    d:=length(b);
    select dbms_lob.compare(a,b,dbms_lob.lobmaxsize,d,e) into f from dual;
    if f = 0 then
       dbms_output.put_line('Same --> '||to_char(f));
    else
       dbms_output.put_line('Diff --> '||to_char(f));
    end if;
    exception
         when others then
              dbms_output.put_line(SQLERRM);
    end;        

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

  • FORMAT WINDOWS 7(64) BY MISTAKEN NOW HOW I RECOVER ERASED DATA WHICH I HAD LOCKED DRIVE BY BIT LOCKER

    i'm using windows 7 (64 bit) but experiment to install mac on my PC (i 5-4 GB ddr 3-500sata sea gate).by mistaken its format my whole hard drive which is 500 GB sea gate sata.after this i'm confused and install windows 8.1 and then again i had install windows
    7 (64 bit) now after 2 time partition erased i'm trying to recover my data 50 percent data but which drive i had locked with windows 7 bit locker it cant recover any thing I've remember its password.
    any one help me to get back my data from this locked drive ?
      

    RB
    If the drive was both formatted and bit locked you cannot recover your data.
    Wanikiya and Dyami--Team Zigzag

  • HT201084 My family shares one Apple ID on multiple devices.  How do I switch everyone over to their own Apple ID without having to erase their iphones and ipads?

    My family currently shares one Apple ID on multiple devices and has for quite awhile.  How do I switch everyone over to their own Apple ID and the Family Sharing without having to erase their iphones and ipads?

    Thank you again for your time, GB.
    I set up individual Apple ID's for my children so that they could have their own Apple ID on their individual iPad minis (gifts from grandparents last year).  When I go to iCloud under Settings, I see my Apple ID listed at the top, then my children's listed under Family Sharing.  So the device is still using my Apple ID for iCloud, iTunes, etc., correct?
    To "assign" their own Apple ID to their own iPad mini, I would need to "Sign Out" from my Apple ID.  When I attempt to do so, I receive a warning that all of the Documents and Data will be lost/deleted. 
    So, instead of doing this, I figured out that I could do what you suggested.  Signing in using a child's Apple ID will allow her/him to use Game Center, FaceTime, and Messages just fine.  However, using their Apple ID for iTunes & App Store proved to be a problem:  Purchased Music and Movies appeared in iTunes, but my Purchased Apps did not appear.  Some Apps even disappeared, e.g. Proloquo4Text (a $99 app to help my son speak with his iPad).
    So I reverted to using my Apple ID for iTunes & App Store, and I get everything that I want, EXCEPT for the iCloud storage for each Apple ID.
    So that's when I started wondering how Family Sharing was really benefiting me ~ It was a lot of work (deleting apps to allow space to download iOS 8, etc) without any benefit that I can see.  UNLESS I find a means to allow me to sign in each iPad's iCloud account with a different AppleID, then perhaps restore the Documents and Data from a backup?  Would that work?
    Thanks.

  • I accidentally erased a music album that I purchased on iTunes. How can I get the iTunes store to recognize that it is no longer in my iTunes library and download it again?

    I accidentally erased a music album that I purchased on iTunes. How can I get the iTunes store to recognize that it is no longer in my iTunes library and download it again?

    Delete the broken links in iTunes then look at your purchased list to redownload.
    If this happened because you were deleting files from the iTunes folder in Finder, don't.  You have to let iTunes do all the deleting and moving or you will end up with broken links.

Maybe you are looking for

  • Safari 2.0.4 quits after 30 seconds everytime

    Hi. Could someone help, my safari quits a few seconds after opening. After reading other discussions ive tried to re-install but as I can only access the internet with Internet Explorer with my classics but it means I cant access the flash player sit

  • Authorization based on AP group

    Hi, I am running WLC 7.4.100 and ISE 1.2. With Flexconnect APs. In ISE I have a condition that say "Radius: Called-Station-ID CONTAINS ssid" in a Policy Set. This works fine and in ISE I can see the attribute on the devices: Called-Station-ID 7c-95-f

  • XPath expressions in XmlCursor / XmlObjects

    Hi all, I tried to get a portion of an XML by using XPath Expressions as follows: String xPathExpression = "declare namespace xq='http://inti.notariado.org/indices' " + "$this/xq:RULES/xq:RULE[@disabled]"; A simple example of an xml <rules> <rule dis

  • File Content Conversion (Sender) endSeparator Problem

    Hi i have a flat file like this: fieldA;fieldB;fieldC;fieldA;fieldB;fieldC;fieldA ... recordset structure: FIELDS,1 recordset per msg: * parameters: FIELDS.fieldNames = fieldA,fieldB,fieldC FIELDS.fieldSeparator = ; FIELDS.endSeparator = ; if i chang

  • IPad Music app crashes while trying to choose my shared Mac music library

    IPad Music app crashes while trying to choose my shared Mac music library.  Only a few of the artists show up and if I try a search, the App crashes.