You are here: Error handling in stored procedure AND checking « MsSQL Server « IT news, forums, messages
Error handling in stored procedure AND checking

Posted by barmatt80 on 01/03/08 18:06

I am stumped on the error reporting with sql server. I was told i
need to return @SQLCode(code showing if successful or not) and
@ErrMsg(and the message returned). I am clueless on this.

I wrote this procedure:

[code]ALTER PROCEDURE [dbo].[usp_AcceptLeaveBalance]

@Emp_SSN int,
@Annual_Forward decimal(10,2),
@Sick_Forward decimal(10,2),
@Family_Forward decimal(10,2),
@Other_Forward decimal(10,2)

AS

UPDATE OT_MAIN

SET

EmpAnnual_Forward = IsNull(@Annual_Forward, EmpAnnual_Forward),
EmpSick_Forward = IsNull(@Sick_Forward, EmpSick_Forward),
EmpFamily_Forward = IsNull(@Family_Forward, EmpFamily_Forward),
EmpOther_Forward = IsNull(@Other_Forward, EmpOther_Forward)

WHERE

Emp_SSN=@Emp_SSN[/code]

I can execute the procedure using this:

[code]exec usp_AcceptLeaveBalance 123456789, 10, 10, null, 10[/code]

Sql comments that it is successful and that 0 rows are changed. I
know it shouldn't be successful because 123456789 does not refer to
any SSN.

So i am just inquring how to do the error handling and secondly I am
guessing I need to check to see if the ssn exists first.

Any suggestions or help.

I greatly appreciate it, and thanks for the help.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация