G'Day,

Given the following:

DROP PROCEDURE [dbo].[sp_Test]
GO

CREATE PROCEDURE [dbo].[sp_Test]  AS

DELETE FROM tblMatches WHERE MatchID = 15
IF @@ERROR <> 0 GOTO Error

RETURN
error:
  RETURN @@ERROR
GO

DECLARE @r as INT
EXEC @r = sp_test
PRINT @r

and the following result

Server: Msg 547, Level 16, State 1, Line 0
DELETE statement conflicted with COLUMN REFERENCE constraint
'FK_tblScoreCardBatting_tblMatches'. The conflict occurred in database
'Cricket2000', table 'tblScoreCardBatting', column 'MatchID'.
The statement has been terminated.
0

Why is the stored proc returning 0? How do I trap the first error??

TIA

------------------------------------------------------------------------
--Donovan
Donovan J. Edye [www.edye.wattle.id.au]
Namadgi Systems, Delphi Developer
Web: www.namsys.com.au E-Mail: [EMAIL PROTECTED]
Voice: +61 2 6285-3460 Fax: +61 2 6285-3459
TVisualBasic = Class(None);
------------------------------------------------------------------------

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to