Updating a CLOB

5 pts.
Tags:
Oracle
I am trying to remove carriage returns at the end of clob fields by using the following in sqlplus: update scbdesc a set a.scbdesc_text_narrative = (select substr(dbms_lob.substr(scbdesc_text_narrative),1, length(scbdesc_text_narrative) -1) from scbdesc b where substr(dbms_lob.substr(b.scbdesc_text_narrative), length(b.scbdesc_text_narrative),1) = chr(10) and a.scbdesc_subj_code = b.scbdesc_subj_code and a.scbdesc_crse_numb = b.scbdesc_crse_numb and a.scbdesc_term_code_eff = b.scbdesc_term_code_eff and a.scbdesc_term_code_end = b.scbdesc_term_code_end) where substr(dbms_lob.substr(a.scbdesc_text_narrative), length(a.scbdesc_text_narrative),1) = chr(10) This just nulls out the field in the table. What do I need to change to make this work? Thanks for your assistance!

Answer Wiki

Thanks. We'll let you know when a new response is added.

Why the complicated join
if the carriage return is at the end of the clob
just
update scbdesc a
set a.scbdesc_text_narrative =
dbms_lob.substr(a.scbdesc_text_narrative,dbms_lob.length(a.scbdesc_text_narrative )-1 ,1 )
where dbms_lob.substr(a.scbdesc_text_narrative,1,dbms_lob.length(a.scbdesc_text_narrative )-1 ) = chr(10);
*********************
NOTE:the dbms_lob.substr parameters are lenght,offset
whereas the substr function parameters are offset,length
*********************
that’s your problem

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Warpmail
    [...] Address: http://itknowledgeexchange.techtarget.com/itanswers/updating-a-clob/ (0) Comments Read [...]
    0 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following