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

Similar Messages

  • Why won't safari 7.o.1 work with silverlight and netflix using mavericks?

    Netflx requires MS Silverlight. After installation Safari leads to the Netflix prompt "thanks for downloading, please restart your browser"--restarting browser doesn't work, nor does restarting computer. Netflix works with Silverlight on Firefox however. So, it seems like a Safari problem. Netflix techs couldn't help. I'm using a MacBook Air with Mavericks. Thank you for any advice on getting Safari (7.0.1) to work with Silverlight with Netflix.

    Neither one of those Safari extensions are beneficial, so I suggest you uninstall them.
    Safari Restore looks like junk. It's no longer required anyway since Safari already incorporates what it allegedly does.
    Folx may have corrupted the Silverlight download, therefore I suggest repeating my above instructions to remove and re-install Silverlight.
    Restart your Mac in "Safe Mode" and determine if you can load a Netflix movie then. Netflix will stream in Safe Mode, but the video is likely to stutter and there may be no audio.
    Please read the following first:
    Safe Mode or "Safe Boot" is a troubleshooting mode that bypasses all third party system extensions and loads only required system components. Read about it: Starting up in Safe Mode
    You must disable FileVault before you can start your Mac in Safe Mode.
    Starting your Mac in Safe Mode will take longer than usual, graphics will not render smoothly, audio is disabled on some Macs, and some programs (iTunes for example) may not work at all.
    Merely starting your Mac in Safe Mode is not intended to resolve the problem, it's to observe its performance without certain additional components.
    To end Safe Mode restart your Mac normally. Shutdown will take longer as well.

  • I had this video file and I was trying to flip it to a format that would work with iMovie.  It used to have the Quicktime image with it.  So, I assume it was a QT file.  But, somehow I've changed the file from a video to a folder.

    I had a video file and I was trying to flip it to a format that would work with iMovie.  It used to have the Quicktime image with it.  So, I assume it was a QT file.  But, somehow I've changed the file from a video to a folder.  I've tried to undo the action.  No luck.  I wasn't running my Time Machine.  So, I can't go back.  Help.  It's the only copy of this video.

    I've tried to undo the action.
    How?
    Please detail ALL you have done so far in the way of troubleshooting?   Need this info to avoid the been there done that scenarios.
    it's the only copy of this video.
    Where did you get the video from?
    From the pic I noticed that the folder is 841.9mb.  What's inside?  Or what happens when you click on it?

  • I had an iphone 4s and it worked nice with facetime and imessage using my phone number but  it was stolen on December so I buy a new iphone 4s using the same cellphone number  but now imessage and facetime does not work with my number, it only works with

    I had an iphone 4s and it worked nice with facetime and imessage using my phone number but  it was stolen on December so I buy a new iphone 4s using the same cellphone number  but now imessage and facetime does not work with my number, it only works with my apple ID.   Please Help me I speak Spanish so  if my English is not ok  I´m sorry about it.
    Do you think that apple has to   reset in their database of the old serial number attached with my phone number and that’s why I can´t activate imessage and facetime with my number in the new iphone 4s?? 

    I understand all of this Meg; that is why I bought an Iphone; but never expected my phone not even give a at least a 24 or even 12 hours....I work 12 hour shifts and also would expect to have to charge each night but not twice a day or more.  I am not always somewhere I can charge my phone.
    Your points are true; however it doesn't help me......

  • Hello , im working with hebrew and the dot  "." isnt correcting to right with the align , i know that in indesign u use with paragraph direction to correct it but here what should i do. sorry for my english

    hello , im working with hebrew and the dot  "." isnt correcting to right with the align , i know that in indesign u use with paragraph direction to correct it but here what should i do. sorry for my english

    You are right, but how could i send it to Apple? when the phone company first replaced my iphone they had in stock alots of iphones and they just sent mine back to Apple and gave me a new one, so all i did is to give them my phone, but now how could i sent it to Apple? and i cant send it by myself, and the store wont do that, its a lost for them.. so sending it to Apple wasnt an option from the begining.
    and for the record, i dont think the store where i bought it is an authorized shop.. its just a store who boughts phone's from Apple in a low price and sells it in much more money..

  • My iPhone 5 its running IOS6.4 and just work with wifi, when I use 3G I can't send or receive any data

    My iPhone 5 its running IOS6.4 and just work with wifi, when I use 3G I can't send or receive any data

    Try resetting all network settings, or turn the airplane mode on then off, or restarting the device itself
    if all else fails, do a restore (Back-up everything before doing this)
    if it still fails, contact apple or your wireless carrier.

  • PC Used to work with XP and airport Extreme Basestation but not with Vista

    Please help, my PC Used to work with XP and airport Extreme Basestation but not now with Vista. I have a MacBook Pro connected and also a Mac Pro connected to the network on it and they still work, i have put the latest software on the PC and the firmware is up to date. The only thing i can see on the network on the PC is the basestation Hard Disk (shared also to the Macs) but i cannot connect with the password, i have tried everything in my knowledge, including formatting the machine and reinsatlling OS and changing security setting to no avail. Any ideas anyone?

    With regard to your printer problem - take a look at this discussion:
    http://discussions.apple.com/thread.jspa?messageID=6312413&tstart=0

  • HT5706 I am trying to set up Apple TV with my Uverse WiFi, but I get errors when entering my password.  One site said that Apple TV doesn't work with WPA which Uverse uses.  Is there anyway around this or will Uverse and Apple TV just not work together.

    Trying to set up Apple TV with ATT Uverse.  I get errors when trying to enter my WiFi password.  One site says that Apple TV doesn't work with Uverse because it uses WPA for encryption.  If true, does that mean Uverse subscribers cannot use Apple TV?

    Spurs63 wrote:
    does that mean Uverse subscribers cannot use Apple TV?
    No, that's a rather silly conclusion.
    There are two options:
    stop using the crappy router provided by the ISP.
    Physically connect the ATV to the router via Ethernet.

  • Problems While Working With CLOB fields

    HI Friends,
    I am facing one big problem while working with CLOB fields. I work in crystal reports in my project and My team is works in BMC Remedy tool. As per database configuration by default the date fields are stored in numbers. There is a field named Work Log which stores the complete history information of a ticket or a call.
    While generating reports I convert the date fields from numbers into date values by using to_date function. But I am not able to change the dates mentioned in the worklog which is a CLOB field. As a result when I am generating reports text part of the work log is comming fine but the date fields are comming in numbers.
    Please refer the below example:-
    *1291012455anilkumarptesting*
    Full Name:
    PRG Name - EUC-APP PKGN1291012585anilkumarptesting
    Full Name:
    PRG Name - EUC-APP PKGN1291012631anilkumarptest
    Full Name:
    PRG Name - EUC-APP PKGN1291207510anilkumarpfd
    Full Name: Anil Kumar Pantangi
    PRG Name - Prod_Ops1291207535anilkumarpf
    Full Name: Anil Kumar Pantangi
    PRG Name - Prod_Ops
    Assignment notification disabled for this transaction1291212517kapilbasd
    Full Name: Anil Kumar Pantangi
    PRG Name - Prod_Ops
    See the first line of the worklog "1291012455anilkumarptesting", 1291012455 is referring a date value, but due to database configuration it's comming in number. All the other numbers in the above text are dates only which need's to be converted. These dates are captured in remedy tool when someone updates that ticket.
    I am not able to decide how to change this numbers into dates. As it is containing lot's of numbers i am really confused how to come with a solution.
    Can I expect a solution from you, atleast a way how to proceed resolving this problem. Should I have to write a procedure for this??
    Please help..........
    Kindly let me know if you need any more input.
    Regards,
    Arijit

    937670 wrote:
    1291012455 represents a date value,What date value does it represent? Since it's not obvious to us what date you want that converted into, it's obviously hard for us to help. For example, perhaps you want that to be Jan 29, 2010 with "12455" representing a time component in some non-obvious format. Perhaps you want that to be December 1991 at 1:24:55. Perhaps you want to convert it to a completely different date. You're going to need to tell us in words how to convert your numeric data into a date.
    My question is how can I convert all the numbers into date in the CLOB field and present it in a proper manner.Given your sample data, what do you expect the output to be? Do you expect many rows of data, one for every date in the CLOB? Do you expect a comma-separated list? Something else?
    Justin

  • Does Streams work with CLOB or not

    Hi,
    Reading the documentation it tells me streams works with CLOB's. So I tried it out and it failed with an unsupported datatype error. I'm using a standard charset (WE8ISO8859P15). So does it work with this charset or not???? (well in may case not :-) It's not really clear to me what charsets are supported.
    Thanks,
    Steve.

    Did you try to replicate whole table with CLOB column in it? It should works..

  • FaceTime no longer working with Yosemite and IOS 8.1

    I have used FaceTime flawlessly for some time with no issue.
    After I upgraded to Yosemite on my MacBookAir and IOS8.1 on 5S and iPad air, I've had a problem connecting.
    When I get a call, all the devices ring (as they should) but it will not connect on the first device I pick up on.  It says connecting
    but all the other devices keep ringing and finally it says I have a missed call.  The connection does not happen.  If I turn off
    all devices except one, it will work...... do we have a bug here??

    Thank you for responding to my issue.  I spent the better part of two hours trying to get this to work.  Bluetooth is enabled on all devices. Each computer is set in Preferences/General to allow Handoff.  All computers and iPhones are on the same WiFi network.  I toggled all of the major settings off and on.  Rebooted each of my computers several times. I finally conceded defeat.  Then my daughter asked to have a try at it.  She worked on the first MBP for about thirty minutes and informed me that she had gotten continuity to work.  And indeed, on her MBP late 2012 she is able to use the continuity features in both directions between her computer and her iPhone 6.  But it only works with Mail and Safari.  I asked how she accomplished this feat.  She said she turned off "everything" on her computer and iPhone (WiFi, Bluetooth, "Allow handoff" under Preferences/General) and then rebooted both the iPhone and the computer.  She then turned everything back on.  This worked for her.  So we tried the same thing on my MBP and iPhone 6.  Now continuity works partially. Email activity is mirrored on both the MBP and the iPhone regardless of which device initiates the continuity activity.  But Safari activity on the computer is mirrored on the iPhone but not in the opposite direction.  There is no continuity function for Pages in either direction.  The telephone connectivity works fine on all of my devices– 3 MBPs, Mac Pro, iPad Air, 2nd gen iPad and 3rd gen iPad.

  • Looking for an app that works with Mac and iPhone that will set calendar reminders of birthdays in contacts.

    Looking for an app that works with Mac and iPhone that will set calendar reminders of birthdays in contacts.

    Hi ron1098,
    Try my application Dates to iCal. it runs on the Mac, but you can sync the calendar to your iOS device.
    See more about Dates to iCal here. It is £4 shareware with a 2 week demo.
    Best wishes
    John M
    As I sell software on my site and ask for donations, the Apple Support Communities Use Agreement requires that I state that I may receive some form of compensation, financial or otherwise, from my recommendation or link.

  • Handoff not working with Yosemite and iOS 8

    I have three Macbook Pros in my household.  Two are mid 2012 models and the other a late 2012 model.  Each is supposed to support the handoff feature of Yosemite and ios8.  Everything seems to work properly between my daughter's late 2012 MBP and her iPhone 6.  But on the other two MBPs in our family the continuity feature does not work on either of them.  Receiving and sending calls works fine.  But the continuity does not work even though all three MBPs and all three iPhone 6 are on the same wifi network.
    I've tried all the suggestions that I could find.  Toggling off and on the various settings on the MBPs and the iPhones.
    John

    Thank you for responding to my issue.  I spent the better part of two hours trying to get this to work.  Bluetooth is enabled on all devices. Each computer is set in Preferences/General to allow Handoff.  All computers and iPhones are on the same WiFi network.  I toggled all of the major settings off and on.  Rebooted each of my computers several times. I finally conceded defeat.  Then my daughter asked to have a try at it.  She worked on the first MBP for about thirty minutes and informed me that she had gotten continuity to work.  And indeed, on her MBP late 2012 she is able to use the continuity features in both directions between her computer and her iPhone 6.  But it only works with Mail and Safari.  I asked how she accomplished this feat.  She said she turned off "everything" on her computer and iPhone (WiFi, Bluetooth, "Allow handoff" under Preferences/General) and then rebooted both the iPhone and the computer.  She then turned everything back on.  This worked for her.  So we tried the same thing on my MBP and iPhone 6.  Now continuity works partially. Email activity is mirrored on both the MBP and the iPhone regardless of which device initiates the continuity activity.  But Safari activity on the computer is mirrored on the iPhone but not in the opposite direction.  There is no continuity function for Pages in either direction.  The telephone connectivity works fine on all of my devices– 3 MBPs, Mac Pro, iPad Air, 2nd gen iPad and 3rd gen iPad.

  • Hello, I have a Mac computer with NVIDIA 750M dedicated graphics card and monitor EIZO but the problem was there when I was working with Windows and Acer monitor. When I open a file from Camera Raw in PS this is smaller than the screen so I double-click w

    Hello, I have a Mac computer with NVIDIA 750M dedicated graphics card and monitor EIZO but the problem was there when I was working with Windows and Acer monitor. When I open a file from Camera Raw in PS this is smaller than the screen so I double-click with the tool "hand" to fit on the screen, but the picture loses sharpness and becomes blurry. If you magnify the image even only slightly with the tool "zoom" the picture comes back clear. In Camera Raw instead is always sharp. I solve the problem by turning off the graphics card in PS but often use plugin that need the graphics card otherwise the processing time is much longer. I ask for help.
    Thanks.

    Hello, I have a Mac computer with NVIDIA 750M dedicated graphics card and monitor EIZO but the problem was there when I was working with Windows and Acer monitor. When I open a file from Camera Raw in PS this is smaller than the screen so I double-click with the tool "hand" to fit on the screen, but the picture loses sharpness and becomes blurry. If you magnify the image even only slightly with the tool "zoom" the picture comes back clear. In Camera Raw instead is always sharp. I solve the problem by turning off the graphics card in PS but often use plugin that need the graphics card otherwise the processing time is much longer. I ask for help.
    Thanks.

  • Internal Microphone not working with Quicktime and some other apps, yet it does for Skype.

    Internal Microphone not working with Quicktime and some other apps, yet it does for Skype. 
    Microphone works fine with Quictime on another mac, so I do know how to use it. The one where it is not working (A) had an external microphone and camera attached earlier, and indeed it does work with that external microphone, but not with the internal microphone selected; and (B) had RealPlayer installed previously.
    Any suggestions, please?

    Hi,
    Download Audio driver from here.
    Intructions how to install it in Vista/Win7.
    Extract this driver with Winrar.
    Open Device manager and expand the Sound, video and game controllers section.
    Right click on Either the High Definition Audio Device if you have the generic Microsoft drivers, or the Conexant High Definition SmartAudio 221 if you have older Conexant drivers and choose "Update Driver Software..."
    Click Browse my computer for driver software, then click "Let me pick from a list of device drivers on my computer"
    Click "Have Disk..." then Browse to the folder where the drivers were extracted  .......\V64 for 64-bit Vista/Win7. Click OK.
    Select one of the "Conexant High Definition SmartAudio 221" models in the list, there will be multiple identical entries.
    Click Next, and you're done.
    I'm not sure which one from the list will work for You.
    This drivers weren't test. So if You will try them and it will work for You let us now about.
    ** Say thanks by clicking the "Thumb up" icon which is on the left. **
    ** Make it easier for other people to find solutions, by marking my answer with "Accept as Solution" if it solves your issue. **

Maybe you are looking for