1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Handling null - values in stored procedures

Discussion in 'SQL PL/SQL' started by oli001, Sep 18, 2009.

  1. oli001

    oli001 Guest


    I think a easy question, but probably I´m totally left out in the dark...

    I have a stored proc with input parameters.

    I do a select on a talble like that:

    select aaa,bbb,ccc
    from mytable
    where ddd like nputValue1
    and eee like inputValue2;

    The problem is, if inputValue2 is null, then I will not receive Data, but if I write "eee is null", the data will be received.

    So, eee can be "Hello" or null and for both it can give some results.

    A possibility is: eee is null then ---> select with "is null", if not select with "like", but there are 12 and´s in my query... 12^2 = 144 select`s ??

    Can someone help me?


  2. debasisdas

    debasisdas Active Member

    Likes Received:
    Trophy Points:
    Bangalore, India
    Can't you simply write a IF block to check if the parameter is null or not and frame the query dynamically at the run time to ignore the parameter.