none
Decode function in SQL Query

    Question

  • Hi,

    I have a sql query where I need to pass an optional parameter if the person id is 1, then it should ask for an optional parameter of company ID. If The person's ID is not equal to 1 then it should not ask for any company ID. How can I handle this in SQL?
    Can I write a decode function in the following way? But its throwing error as missing right paranthesis..

    select *
    from table1
    where  DECODE( PersonID,'1', CompanyID in (:PCompanyID), PersonID)

    Please help me!!

    Thank you.

    Tuesday, June 21, 2011 6:02 PM

Answers

All replies