Solved

SELECT Records based on octal or decimal value at the end of a string

Posted on 2014-02-25
7
378 Views
Last Modified: 2014-02-25
I need to select records from a table if they have a certain decimal value at the end of the string.  After an import we get many records that contain decimal value 13 as the final character.  I determined that based on doing a dump in PL/SQL.

select '('||website||')', dump(website)
from business
----------

I get the following:
(sunshinecavaliers.com ), Typ=1 Len=22:115,117,110,115,104,105,110,101,99,97,118,97,108,105,101,114,115,46,99,111,109,13

Now, that I know my problem records contain a decimal value of '13' I want to search my entire DB to find all records that contain the '13' at the end of the website field.
0
Comment
Question by:bretthonn13
7 Comments
 
LVL 35

Expert Comment

by:YZlat
Comment Utility
SELECT * FORM TAble1 WHERE Field1 LIKE '%13'
0
 
LVL 73

Accepted Solution

by:
sdstuber earned 500 total points
Comment Utility
decimal character 13 is a carriage return rather than searching on the dump output
just search for that character



select '('||website||')', dump(website)
from business
where website like '%' || chr(13)


note, looking for trailing characters is not normally going to be something you can use an index, so this query might take a while if you have many rows
0
 
LVL 31

Expert Comment

by:awking00
Comment Utility
select * from business
where instr(website,chr(13)) = length(website);
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 73

Expert Comment

by:sdstuber
Comment Utility
>>>  instr(website,chr(13)) = length(website);

same idea as LIKE '%' ||13 but more expensive to execute
0
 
LVL 31

Expert Comment

by:awking00
Comment Utility
I agree and wouldn't have even posted my suggestion except I wrote it much earlier but never submitted it after I received a phone call and never even saw the other responses. I was going to withdraw it, but apparently cannot after a new comment has been submitted. You're just too fast, Sean :-)
0
 

Author Comment

by:bretthonn13
Comment Utility
decimal character 13 is a carriage return rather than searching on the dump output
just search for that character



select '('||website||')', dump(website)
from business
where website like '%' || chr(13)


It works great.  Unfortunately I have far more records with problems than I thought.  I should be able to update those records and simply remove the chr(13) though right?
0
 
LVL 73

Expert Comment

by:sdstuber
Comment Utility
doing the update is easy, but only you can decide if it's ok to do so or not.

update business
set website = rtrim(website,chr(13))
where website like '%' || chr(13)
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Add 0 to end of Number 21 70
Export BLOB data from Oracle 10g 4 23
T-SQL Convert to PL/SQL 23 59
null value 14 57
Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now