MySQL Forums
Forum List  »  Newbie

Dynamic WHERE (BIT parameter)
Posted by: Martin Beaudet
Date: December 19, 2009 01:24AM

Hi,

Here is my table Report and some rows to understand what I need :

ID           ClosedDate
1            2009-10-10
2            NULL
3            2009-10-12
4            NULL
5            2009-10-14

In a stoed procedure I'm receiving a parameter that specify if I want to hide closed report from my query result.

So when the parameter (hideClosedDateReport) IS NULL or has a value of 0 then the query must returns all the rows. If the has a value of 1 then the query must only output the date having ClosedDate NULL.

CREATE PROCEDURE (hideClosedDateReport BIT)
(
    SELECT ID, ReportEndingDate
    FROM Report
    WHERE (hideClosedDateReport IS NULL OR hideClosedDateReport = 0)
          OR (hideClosedDateReport = 1 AND ClosedDate IS NOT NULL)
)

I also tried others combinaison but without success...

Options: ReplyQuote


Subject
Written By
Posted
Dynamic WHERE (BIT parameter)
December 19, 2009 01:24AM
December 19, 2009 10:15AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.