July 28, 2009 at 12:09 am
Hi every one. My logic is failing me.... still scratching my head...
I have 2 variables.
The proc should allow both variables to be null.
But if one is specified, then the other should be specified as well.
And I do not want very complex validion code. it should be simple small blocks of code.
For instance, one validation is to check that the unit is passed to the proc
Simple, and effective
if isnull(UnitID,0) = 0
Begin
Raiserror('Please Specify Unit', 16,1)
Goto BatchEnd
End
Now back to the tricky validation :
I can come up with multiple ways to do the validation, but they will all be at least one full page of code, with heavy nested if statements and multiple goto statements. I hate Goto. Will this be the only way, or is there a simpler solution?
The following should fail.
[Code]
Declare @RetailDateFrom datetime
Declare @RetailDateTo datetime
Set @RetailDateFrom = '2009-07-28 12:00:00'
Set @RetailDateTo = null
[/Code]
Now these 2 shoud pass:
[Code]
Declare @RetailDateFrom datetime
Declare @RetailDateTo datetime
Set @RetailDateFrom = '2009-07-01 12:00:00'
Set @RetailDateTo = '2009-07-01 12:00:00'
[/Code]
AND
[Code]
Declare @RetailDateFrom datetime
Declare @RetailDateTo datetime
Set @RetailDateFrom = null
Set @RetailDateTo = null
[/Code]
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply