Solved

Using a wildcard or LIKE statement inside a DECODE

Posted on 2004-08-19
3
1,593 Views
Last Modified: 2008-02-26
I am trying to use a decode statement to translate a statement into a true/false values.
I have tried using:
DECODE( A.Problem_History, '%Duplicated%', 'True', 'False')
DECODE( A.Problem_History, '*Duplicated*', 'True', 'False')
but neither of those work for finding those which contain the work 'Duplicated' in the Problem_History column.

My next thought was to try a LIKE statement and if its true, pass 'True' as the returned value.
DECODE( (A.Problem_History LIKE '%Duplicated%'), 'True', 'True', 'False')

This however returns a "ORA-00907: Missing right parenthesis" error and highlights the 'LIKE' keyword.

0
Comment
Question by:Pawlikj
  • 2
3 Comments
 
LVL 69

Expert Comment

by:ScottPletcher
Comment Utility
You will likely have better luck placing this in the Oracle forum rather than the SQL Server one :-)
0
 
LVL 10

Expert Comment

by:Jay Toops
Comment Utility
AND you cant use like in a decode statement ..
0
 
LVL 10

Accepted Solution

by:
Jay Toops earned 250 total points
Comment Utility
you can do this though

case when A.Problem_History like '%duplicated%' then 'true'
else 'false'
end as bDuplicated
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

771 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

10 Experts available now in Live!

Get 1:1 Help Now