473,323 Members | 1,589 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

Stored Procedure... pls help

Create PROCEDURE NextGen_ConvertDate_Deven AS
declare @DLSStart smalldatetime

set @DLSStart = (select dbo.fn_GetDaylightSavingsTimeStart(convert(varchar ,datepart(year,getdate()))))
/* please Note this funcution (fn_GetDaylightSavingsTimeStart) returns values is 2008-03-09 02:00:00 */


update NexGen_New_Losses_Deven
set F37_CLAIM_ENTERED_S_DT_conv =

CASE
WHEN XM_REPORTING_MCO_NM = 'HUDSON EXPRESS OFFICE'
OR XM_REPORTING_MCO_NM = 'CHARLOTTE EXPRESS OFFICE'
OR XM_REPORTING_MCO_NM = 'INDIANAPOLIS EXPRESS'
AND F37_CLAIM_ENTERED_S_DT <= @DLSStart -- 2008-03-09 02:00:00
THEN dateadd (hour, -5 ,F37_CLAIM_ENTERED_S_DT ) --WINTER
WHEN XM_REPORTING_MCO_NM = 'HUDSON EXPRESS OFFICE'
OR XM_REPORTING_MCO_NM = 'CHARLOTTE EXPRESS OFFICE'
OR XM_REPORTING_MCO_NM = 'INDIANAPOLIS EXPRESS'
AND F37_CLAIM_ENTERED_S_DT > @DLSStart -- 2008-03-09 02:00:00
THEN dateadd (hour, -4 ,F37_CLAIM_ENTERED_S_DT )

ELSE NULL

END
------------------------------------
when I run this stored procedure, it updates only first case of WHEN for each state, no matter what date I entered here. for example, always it reduce 5 hours for hudson, charlotte and Indianapolis and not reducing 4 hours for any date of year. I have a doubt that stored procedure doesn't like my @DLSStart variable. please advice...

Thanks
Deven
Oct 23 '08 #1
2 1245
ck9663
2,878 Expert 2GB
Group your conditions together by using parenthesis.

It's similar to

2 * 3 + 5 = 11

vs

2 * (3 + 5) = 16

Group your OR together and leave the AND outside...

Expand|Select|Wrap|Line Numbers
  1. update NexGen_New_Losses_Deven
  2. set F37_CLAIM_ENTERED_S_DT_conv =
  3.  
  4. CASE
  5. WHEN (XM_REPORTING_MCO_NM = 'HUDSON EXPRESS OFFICE'
  6. OR XM_REPORTING_MCO_NM = 'CHARLOTTE EXPRESS OFFICE'
  7. OR XM_REPORTING_MCO_NM = 'INDIANAPOLIS EXPRESS')
  8. AND F37_CLAIM_ENTERED_S_DT <= @DLSStart -- 2008-03-09 02:00:00
  9. THEN dateadd (hour, -5 ,F37_CLAIM_ENTERED_S_DT ) --WINTER
  10. WHEN (XM_REPORTING_MCO_NM = 'HUDSON EXPRESS OFFICE'
  11. OR XM_REPORTING_MCO_NM = 'CHARLOTTE EXPRESS OFFICE'
  12. OR XM_REPORTING_MCO_NM = 'INDIANAPOLIS EXPRESS')
  13. AND F37_CLAIM_ENTERED_S_DT > @DLSStart -- 2008-03-09 02:00:00
  14. THEN dateadd (hour, -4 ,F37_CLAIM_ENTERED_S_DT )
  15.  
  16. ELSE NULL
  17.  
  18. END
  19.  

Happy Coding!

-- CK
Oct 24 '08 #2
Oh my God!!!! It's working now, yes it is working... Thanks a lot!!!!
Happy Coding :-)


Group your conditions together by using parenthesis.

It's similar to

2 * 3 + 5 = 11

vs

2 * (3 + 5) = 16

Group your OR together and leave the AND outside...

Expand|Select|Wrap|Line Numbers
  1. update NexGen_New_Losses_Deven
  2. set F37_CLAIM_ENTERED_S_DT_conv =
  3.  
  4. CASE
  5. WHEN (XM_REPORTING_MCO_NM = 'HUDSON EXPRESS OFFICE'
  6. OR XM_REPORTING_MCO_NM = 'CHARLOTTE EXPRESS OFFICE'
  7. OR XM_REPORTING_MCO_NM = 'INDIANAPOLIS EXPRESS')
  8. AND F37_CLAIM_ENTERED_S_DT <= @DLSStart -- 2008-03-09 02:00:00
  9. THEN dateadd (hour, -5 ,F37_CLAIM_ENTERED_S_DT ) --WINTER
  10. WHEN (XM_REPORTING_MCO_NM = 'HUDSON EXPRESS OFFICE'
  11. OR XM_REPORTING_MCO_NM = 'CHARLOTTE EXPRESS OFFICE'
  12. OR XM_REPORTING_MCO_NM = 'INDIANAPOLIS EXPRESS')
  13. AND F37_CLAIM_ENTERED_S_DT > @DLSStart -- 2008-03-09 02:00:00
  14. THEN dateadd (hour, -4 ,F37_CLAIM_ENTERED_S_DT )
  15.  
  16. ELSE NULL
  17.  
  18. END
  19.  

Happy Coding!

-- CK
Oct 24 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Michael Trosen | last post by:
Hi Everyone, I hope someone can help, I'm pretty new to pro*c programming. I have the following application setup: a pro*c program calls a stored procedure and recieves a cursor back: the...
3
by: dinesh prasad | last post by:
I'm trying to use a servlet to process a form, then send that data to an SQL server stored procedure. I'm using the WebLogic 8 App. server. I am able to retrieve database information, so I know my...
3
by: Jarrod Morrison | last post by:
Hi all Im relatively new to using stored procedures and im not sure if it is possible to do what I am trying to do so any help here is greatly appreciated. I am using the variable @MachineName...
7
by: Douglas Buchanan | last post by:
I can't seem to open SQLS2k Stored Procedures in the IDE I am running MDE 2003 Version 7.1.3088 I have a MSDN professional subscription and did a complete install of vs.net Help explains how...
4
by: marc | last post by:
I've been developing a stored procedure that uses a user defined function in the query portion of the procedure. However, since the end product needs to allow for dynamic table names, the UDF will...
3
by: Rhino | last post by:
I've spent the last couple of hours trying to figure out how to debug a Java stored procedure and am just going in circles. The last straw came when I got "Cannot open input stream for default"...
5
by: microsoft.private.windows.netserver.setup | last post by:
I have a very strange thing occurring in the program. I have a dataset retrieved from a stored procedure that just select * from a table. I then try to use the SQlCommandBuilder on the dataset,...
7
by: eholz1 | last post by:
Hello PHP group, Could someone help me out? I have PHP 5.2, Apache 2.0, and MySQL 5.0 running on Linux (Redhat Fedora Core 6). All that works fine. I would like to be able to "call" a stored...
9
by: jyothi1105 | last post by:
Hi all, Here is some information which could help people who want to create stored procedures and execute them in their program. You can create stored procedures in two ways: Through front end...
0
by: SOI_0152 | last post by:
Hi all! Happy New Year 2008. Il hope it will bring you love and happyness I'm new on this forum. I wrote a stored procedure on mainframe using DB2 7.1.1 and IBM language c. Everything works...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.