#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    2
    Rep Power
    0

    Question Using decode in IN clause


    Hi

    Does anyone know if I can use DECODE in an IN clause to do the following:

    select x
    from table
    where code = (parm_value, NULL, code, parm_value)

    In the parameter value I want to specify a list of values to compare against code.
    I have tried putting brackets around parm_value but this doesn't work.

    thanks.
  2. #2
  3. No Profile Picture
    Senior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Canada
    Posts
    305
    Rep Power
    11
    I think you can use it , check out the follwoing example:

    SELECT empno,ename,sal,deptno
    FROM emp
    WHERE deptno in (90,40,decode(deotno,10,10,20))
    /
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    2
    Rep Power
    0
    Hi

    Thanks for that but I don't think its exactly what I want - I need to pass in a parameter which contains a list of values or it can be NULL. Where it contains a list of values I want all of them to be used for the IN CLAUSE

    so if the parameter was (1, 2, 3, 4) the IN CLAUSE would check against all 4 values?

    thanks, Monica.

IMN logo majestic logo threadwatch logo seochat tools logo