?
Solved

sql, if then else in stored procedure

Posted on 2013-01-14
3
Medium Priority
?
366 Views
Last Modified: 2013-01-14
Hi All,

I'm trying to do the below and not so great at sql.  Can anyone help me with the following statement?

.  This will be in a stored procedure
same concept as if then else...  but i dont think it can be a case

This is my original.

UPDATE dbo.DailyPositions_JEFF
SET [P&L Settlement]= (((ISNULL([Delta Settlement],0)*[Value 1Point])*[Local Rate])*[Qty_Net])

Open in new window


I want to say...
If [Value 1Point] = 0.9999
Then
do this
SET [p&L Settlement] =
[delta settlement] *
(1/[tick_size]) *[tick_value]
*
[local rate]

else.... do this

SET [P&L Settlement]= (((ISNULL([Delta Settlement],0)*[Value 1Point])*[Local Rate])*[Qty_Net])



thanks for all the help
0
Comment
Question by:solarissf
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 32

Accepted Solution

by:
Ephraim Wangoya earned 2000 total points
ID: 38774138
Case will still work, here

UPDATE dbo.DailyPositions_JEFF
SET [P&L Settlement] =
	case
		when [Value 1Point] = 0.9999 then
			(((ISNULL([Delta Settlement],0)*[Value 1Point])*[Local Rate])*[Qty_Net])
		else
			[delta settlement] * (1/[tick_size]) *[tick_value]*[local rate]
	end

Open in new window

0
 

Author Comment

by:solarissf
ID: 38774145
ahha.... I didnt know that... kinda looks like a iF ELSE anyway.
looks that this will work... thanks!!!  I'll try it out
0
 

Author Comment

by:solarissf
ID: 38774532
worked... thank you!!!

another question in terms of performance and speed.

which is faster..
1.   to use the case ... else
or
2.  have the stored procedure call a scalar function
scalar function using pulled in paramaters will a true if else
?
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
After restoring a Microsoft SQL Server database (.bak) from backup or attaching .mdf file, you may run into "Error '15023' User or role already exists in the current database" when you use the "User Mapping" SQL Management Studio functionality to al…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question