Tip

How to find carriage returns in data

There are instances when users mistakenly enter a carriage return -- while entering an address, for example. This basically screws up the record and creates problems while processing it. One of the problems that can happen is that part of the address field (or any other field) in which the user has entered a carriage return will end up as data for some other field.

Here's how to deal with this problem. I save this script as CR.sql and run it at the SQL prompt. I have one record in my table which has carriage return in the ADDR1 field. This is what it looks like:

SQL>@CR 

ACCTID           ADDR1                          INSTR(ADDR1,CHR(13)) 
---------------- ------------------------------ -------------------- 
DUMPADDR1 
------------------------------------------------------------------------------- 
-------------------- 
ADDR2                          INSTR(ADDR2,CHR(13)) 
------------------------------ -------------------- 
DUMPADDR2 
--------------------------------------------------------------------------------
-------------------- 
emorial Pky      450 Veterans      14 
Typ=1 Len=25: 52,53,48,32,86,101,116,101,114,97,110,115,32,13,101,109,111,114,10 
5,97,108,32,80,107,1 
21 

NULL 

Here is the the code for CR.sql:

set pages 100 arraysize 1 
select distinct acctid,addr1,instr(addr1,chr(13)),dump(addr1)   dumpaddr1,addr2, 
instr(addr2,chr(13)), dump(addr2)  dumpaddr2 
from org 
where instr(addr1,chr(13))!=0

    Requires Free Membership to View

/

For More Information

  • What do you think about this tip? E-mail the Editor at tdichiara@techtarget.com with your feedback.
  • The Best Oracle Web Links: tips, tutorials, scripts, and more.
  • Have an Oracle tip to offer your fellow DBA's and developers? The best tips submitted will receive a cool prize--submit your tip today!
  • Ask your technical Oracle questions--or help out your peers by answering them--in our live discussion forums.
  • Check out our Ask the Experts feature: Our SQL, database design, Oracle, SQL Server, DB2, metadata, and data warehousing gurus are waiting to answer your toughest questions.

This was first published in April 2002

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

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
Sort by: OldestNewest

Forgot Password?

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

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.