Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old May 10th, 2004, 09:24 PM
cuthbert80 cuthbert80 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 1 cuthbert80 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Problem with Case Statement

Hi Guys,

I am trying to bring back a value to use as a starting month for a reporting period.

I am on ORACLE 9i and my CASE statement causes my app to hang.

The case statement I am using is as follows


case when (SUBSTR(SYSDATE, 4, 2) = SUBSTR(MAX(EMPIT.PIT_RUN_DATEC), 4, 2)) AND (TO_CHAR(SYSDATE, 'dd/mm/yyyy') >= TO_CHAR(MAX(EMPHS.PHQ_PAY_DATEC), 'dd/mm/yyyy')) then to_char(add_months(last_day(SYSDATE), -13), 'yy-mm')
when (MAX(EMPIT.PIT_RUN_DATEC) = LAST_DAY(MAX(EMPIT.PIT_RUN_DATEC))) AND (TO_CHAR(SYSDATE, 'dd/mm/yyyy') >= TO_CHAR(MAX(EMPHS.PHQ_PAY_DATEC), 'dd/mm/yyyy')) then to_char(add_months(last_day(SYSDATE), -13), 'yy-mm')
else to_char(add_months(last_day(SYSDATE), -14), 'yy-mm')
end

The strange thing is, when I change the second condition in the two 'when' clauses, I get back a value but its not correct ofcourse because I have changed my original rule. This is the changed syntax:

case when (SUBSTR(SYSDATE, 4, 2) = SUBSTR(MAX(EMPIT.PIT_RUN_DATEC), 4, 2)) AND (SUBSTR(SYSDATE, 4, 2) = SUBSTR(SYSDATE, 4, 2)) then to_char(add_months(last_day(SYSDATE), -13), 'yy-mm')
when (MAX(EMPIT.PIT_RUN_DATEC) = LAST_DAY(MAX(EMPIT.PIT_RUN_DATEC))) AND (SUBSTR(SYSDATE, 4, 2) = SUBSTR(SYSDATE, 4, 2)) then to_char(add_months(last_day(SYSDATE), -13), 'yy-mm')
else to_char(add_months(last_day(SYSDATE), -14), 'yy-mm')
end

Can anyone see a problem with my first case statement?

Kind Regards

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Problem with Case Statement


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway