Rule Definition
Not returning a status value can lead to data corruption and incorrect behaviour.
Remediation
Always use the RETURN value to return a stored procedure status. RETURN 0 to indicate success and any non-zero value indicates failure.
Violation Code Sample
create proc checkcontract @titleid tid
as
if (select contract from titles where
title_id = @titleid) = 1
select 1
else
select 2
GO
Fixed Code Sample
create proc checkcontract @titleid tid
as
if (select contract from titles where
title_id = @titleid) = 1
return 1
else
return 2
GO
Reference
https://docs.microsoft.com/fr-fr/sql/t-sql/language-elements/return-transact-sql?view=sql-server-ver15
http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc36272.1572/html/commands/X44808.htm
Related Technologies
Technical Criterion
Programming Practices - Error and Exception Handling
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.