Hi, I need a T-SQL Stored Proceduer defined for MS-SQL 2000
The purpose of the Stored Proceduer will be to subtract 1 (ONE) from a stored integer in a field.
Here's the complete scenario:
I have a table with 5 columns, one of the columns holds integer values. I want to pass two variables to the proceduer, namely @orderno and @email based on which the SELECT statement will fetch the right record.
From this record the Integer number field will have 1 subtracted from it and the record in the database updated.
In other words: using for example the ordernumber: 12345 and email support@example.com the integer field "slots" is accessed in the SELECT statement SELECT slots from tblUser where tblUser.orderno = @orderno AND tblUser.email = @email
The stored proceduer should run this select statement and then subtract 1 (-1) from the slots field and update the record.
Also, in an IF statement or likewise, the stored proceduer should check that the number in the slots field is != 0 if it is, then the subtraction should not take place.
The stored proceduer should do this everytime it's executed.
Since thios is SQL 2000 and not 2005 hence TRY/CATCH exception handling is not available either. Any suggestions for appropriate error handling would be appreciated.
Am using ASP.NET (VB.NET) for FrontEnd if that's helpful.
Start Free Trial