Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 display error message on screen if no value

Author  Topic 

parry02
Starting Member

18 Posts

Posted - 2006-08-09 : 05:44:51
I have a screen set up in another software package which accepts
2 values on a form -

'Number1' and 'Number2'

I need to check that at least a value is entered in one or both ...
If both values are 0 (set on dispaly of the form )then I need
to throw an error message to that effect on screen ....

(The Sql script is triggered after the form data has been entered)

Can anyone help me with the SQL script please to check the values ???

mwjdavidson
Aged Yak Warrior

735 Posts

Posted - 2006-08-09 : 06:00:40
Do this validation client-side in your front-end app before going to the db.

Mark
Go to Top of Page

GavinD1977
Yak Posting Veteran

83 Posts

Posted - 2006-08-09 : 06:39:23
Have to agree with mwjdavidson.

Howevere if you want to do it via script, i think your looking at using a CASE statement.
Go to Top of Page

parry02
Starting Member

18 Posts

Posted - 2006-08-09 : 06:48:46
i have to do it in the form via sql script - i cannot do it prior to the processing as its an online form accepting data and validation is online
Go to Top of Page

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-08-09 : 07:02:48
somthing like this

Create proc CheckValues
(
@pValue1 int,
@pValue2 int
)
Begin
Declare @strErr varchar(1000)
if @pValue1 = 0 And @pValue 0
RaiseError('Values cannot be 0',16,1)
End


Chirag
Go to Top of Page

mr_mist
Grunnio

1870 Posts

Posted - 2006-08-09 : 08:12:10
If you do this in sql using RAISERROR then your application still has to parse that result somehow to return that error to the user. Your best bet is to validate the entry before sending it, avoiding the round-trip and processing time, and some messy coding.

-------
Moo. :)
Go to Top of Page
   

- Advertisement -