?
Solved

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

Posted on 2014-02-25
7
Medium Priority
?
386 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
[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
7 Comments
 
LVL 35

Expert Comment

by:YZlat
ID: 39886475
SELECT * FORM TAble1 WHERE Field1 LIKE '%13'
0
 
LVL 74

Accepted Solution

by:
sdstuber earned 2000 total points
ID: 39886490
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 32

Expert Comment

by:awking00
ID: 39886532
select * from business
where instr(website,chr(13)) = length(website);
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 74

Expert Comment

by:sdstuber
ID: 39886539
>>>  instr(website,chr(13)) = length(website);

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

Expert Comment

by:awking00
ID: 39886564
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
ID: 39886798
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 74

Expert Comment

by:sdstuber
ID: 39886869
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
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

770 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