• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1759
  • Last Modified:

Using a wildcard or LIKE statement inside a DECODE

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
Pawlikj
Asked:
Pawlikj
  • 2
1 Solution
 
Scott PletcherSenior DBACommented:
You will likely have better luck placing this in the Oracle forum rather than the SQL Server one :-)
0
 
Jay ToopsCommented:
AND you cant use like in a decode statement ..
0
 
Jay ToopsCommented:
you can do this though

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

Featured Post

Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now