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

Join the conversationComment
Share
Comments
Results
Contribute to the conversation