Statement returing True/False in decode() function

From: Walt <walt_at_boatnerd.com.invalid>
Date: Wed, 13 Aug 2003 16:56:00 -0400
Message-ID: <3F3AA5E0.AAAC1831_at_boatnerd.com.invalid>


Hi,

I want to write a query that returns Y or N depending on whether the current time is within a specified window i.e.

EVENT_TABLE


event_id    number PK
event_start date
event_end   date

I tried this:
  SELECT event_id,

         decode( sysdate between event_start and event_end, TRUE, 'Y', 'N')

    FROM event_table

Unfortunately, Oracle won't accept a boolean expression inside the decode function.

I've accomplished what I want via a correlated sub-query:

SELECT event_id,

   nvl((SELECT 'Y' from event_table e2

         WHERE sysdate between event_start and event_end 
           AND  e.event_id=e2.event_id),'N')
  FROM event_table e

But I'm wondering if there's a more aesthetic way to do it. Is there a way to feed an expression that evaluates to true-or-false to the first argument of the decode function?

Thanks.

-- 
//-Walt
// 
//
Received on Wed Aug 13 2003 - 22:56:00 CEST

Original text of this message