?
Solved

Display control code, or non-printable character within string

Posted on 2014-01-29
10
Medium Priority
?
2,311 Views
Last Modified: 2014-01-29
I have found several records that look to contain trailing spaces after a number, but I cannot query them based on the string containing a space so I believe the records have some sort of control code or no-printable character in them.  I can select the records based on them containing something other than a number or letter, but I want to be able to see what the record really contains.  

Here is how I found the records:

select '('||month||')'
from birthdates
where nvl(length(translate(month,'a1234567890','a')),-1) > 0
/

The records returned look like this:
(1  )
(2  )
(9  )
etc.

They are not spaces that follow the numbers but I cannot find out what they are.  Basically I need to update the records to just show the month number.  The data is mostly accurate  (containing just the number with nothing following) but there are 100's that appear like the above.
0
Comment
Question by:bretthonn13
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
10 Comments
 
LVL 77

Assisted Solution

by:slightwv (䄆 Netminder)
slightwv (䄆 Netminder) earned 2000 total points
ID: 39818987
>>but I want to be able to see what the record really contains

use DUMP to show the hex codes:
select DUMP(month) ...

>>update the records to just show the month number

update birthdates set months=regexp_replace(month,[^0-9]);
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 39818995
Had a typo above (missed a +):
update birthdates set months=regexp_replace(month,[^0-9]+)


Can add a where clause if you wish:
update birthdates set months=regexp_replace(month,[^0-9]+) where regexp_like(month,'[^0-9]+);
0
 

Author Comment

by:bretthonn13
ID: 39819031
Thanks!

I took a look and this is what it returned:
month      dump(month)
5               Typ=1 Len=2: 53,13
5               Typ=1 Len=2: 53,13
6               Typ=1 Len=2: 54,13
6               Typ=1 Len=2: 54,13

So what is this telling me?
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 39819037
The 13 is a Carriage Return.

www.asciitable.com
0
 

Author Comment

by:bretthonn13
ID: 39819057
So in the future if I knew I had a bunch of "13's" or Carriage Returns in some data, can you simply search or select those records containing only Carriage REturns?
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 39819066
>> can you simply search or select those records containing only Carriage REturns?

Sure:
select month from birthdates where instr(month,chr(13)) > 0;
0
 

Author Comment

by:bretthonn13
ID: 39819227
I think it's going to work but I keep getting "error at line 2 missing expression"

update birthdates
set month = regexp_replace(month,[^0-9]+)
where regexp_like(month,[^0-9]+)
and city = 182
0
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 2000 total points
ID: 39819238
Typo:

update birthdates
set month = regexp_replace(month,'[^0-9]+')
where regexp_like(month,'[^0-9]+')
and city = 182
0
 

Author Closing Comment

by:bretthonn13
ID: 39819258
Super fast and exactly what I was looking for!
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 39819432
Glad to help and sorry for the syntax error.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question