?
Solved

ORACLE SQL/PL   case statement - using with IN LIST

Posted on 2007-10-11
3
Medium Priority
?
3,511 Views
Last Modified: 2013-12-07
Hi all,
I have writtent he following CASE Statement in the
criteria for DeptID
DEPTID =
CASE :1 WHEN '12345'  
THEN   '555111'   END  -- This works and brings back the specified department.
I have tried many ways to add more deparment numbers but I get a an error.
I've tried
CASE :1 WHEN '12345'  
THEN IN ("555111','12345')

also I have tried:
CASE :1 WHEN '12345'  
THEN DEPTID IN ("555111','123456')
The only one that works is when I have only one department number.  Is this because CASE statements bring only bring back 1 result?
Thanks much for your help.
Syhctl

Is there a way for me to list more than one dept number in a Case Statement without have to create multiple Statements?
Thanks,
Syhctl
0
Comment
Question by:syhctl
3 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 1000 total points
ID: 20060973
do not use CASE statement...

WHERE ( :1 = '12345' AND  yourfield IN ("555111','12345'))
0
 
LVL 18

Expert Comment

by:sventhan
ID: 20061399
0
 
LVL 23

Assisted Solution

by:paquicuba
paquicuba earned 1000 total points
ID: 20065195
Try this one:

WHERE
CASE :1 WHEN '12345'  
THEN DEPTID END IN ("555111','123456')
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

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

How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This video shows how to recover a database from a user managed backup
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.
Suggested Courses

621 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