December 2, 2008 at 2:46 pm
Is there any way to determine if a stored procedure was passed a parameter if the value matches the default?
CREATE PROCEDURE uspTest (
@Param INT = 0
)
AS
blah.........
Can I tell the difference from within the procedure if I call EXEC uspTest @Param = 0 VS. EXEC uspTest?
December 2, 2008 at 2:58 pm
No way that I am aware of. Why would you need to know that information anyways? If you are going to do something different based upon whether or not the parameter was actually passed in - make sure the default is something that would never be passed in the first place.
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
December 2, 2008 at 3:26 pm
That's how I was going to approach it, just wanted to see if there were other options. Thanks for the feedback!
December 2, 2008 at 4:23 pm
You could always make your defaults null and then test/assign values as the first part of your proc. For example if you wanted the number 8 to be the default for the first parm, see below.
I'm still curious as to why you would want a different result.
declare @parm1Passed char(1)
set @parm1Passed = 'N'
If @parm1 = 8
Begin
set @parm1Passed = 'Y'
End
If @parm1 is null
Begin
set @parm1 = 8
End
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
December 2, 2008 at 4:52 pm
I am still curious as to why you need to know if a parameter was passed in or not. It really shouldn't matter.
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
December 2, 2008 at 5:20 pm
Ok, Jeffrey... I'll hold him while you beat the answer out of him 😉
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
December 2, 2008 at 7:12 pm
Heh... if you need to borrow some porkchops... 😀
--Jeff Moden
Change is inevitable... Change for the better is not.
December 2, 2008 at 10:22 pm
Naw - have plenty of pork chops, I just need something to sling them with :w00t:
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
December 3, 2008 at 8:34 am
Note to self.... invent and patent pork chop slinger... the infomercials are going to be hilarious.
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
December 3, 2008 at 8:39 am
Let me get in on that!
December 3, 2008 at 8:45 am
My current thinking is along the lines of a trebuchet.
Next year I'm going to have one down by my dock. Most of my buddies find no flaws in the idea of spending a day down by the lake with a cooler, a bunch of old tennis balls, and a trebuchet.
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
December 3, 2008 at 11:49 am
Yikes - Dip, Dive, Duck and Dodge! Doesn't pay to leave the forums for a few hours.
Here's the scenario - I'm taking an existing procedure that historically examined each parameter value against a known default, and if different ( and different from the existing record as well), updated a record. If the procedure had 10 params, one being the key, then it would check the other 9 params, and perform an update to the same record for each difference ( I wouldn't claim to have written this if my life was in jeopardy - even at risk of pork chops! ). I think this design was chosen to handle pre/post column level auditing.
The DAL would only pass in "changed" columns via the interface, so chances are we'd only ever get in 3 or fewer updates per record per request - still unacceptable.
I'd like to change this to a single update call, with null defaults in order to lower impact on the frontend/DAL.
So, if I were able to determine that a null value was passed into the procedure vs set as a default value, I could perform the update with a case statement. I can still do with the the default values, was just checking to see if there was an alternative.
December 3, 2008 at 2:03 pm
Aw rats.....
(putting down borrowed pile of pork chops)
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
December 3, 2008 at 2:37 pm
Bummer - my new slingshot is back-ordered. Should be available and delivered in the next 6 to 8 weeks, shipping & handling charges extra (of course) :hehe:
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
December 3, 2008 at 3:56 pm
Bob Hovious (12/3/2008)
My current thinking is along the lines of a trebuchet.
Huh? Don't you watch the Science Channel? Air Cannons are where its at, more than twice the range and muzzle velocity of a trebuchet.
:w00t:
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
Viewing 15 posts - 1 through 15 (of 18 total)
You must be logged in to reply to this topic. Login to reply