October 7, 2002 at 4:03 am
I noticed that the error I raised in my trigger does not have any effect on the sproc that triggers it.
The trigger is an INSTEAD OF UPDATE for the Job table. The code block that raises an error in the trigger looks like this
IF (@newStyleId != @oldStyleID) AND EXISTS(SELECT 'YES' FROM Bundle B
JOIN Assignment A ON B.bundleId = A.bundleId) BEGIN
RAISERROR('You can not change the style of the job because somebody
is already working on it.',16,1)
RETURN
END ELSE BEGIN
UPDATE Job SET styleId = @newStyleId
WHERE jobId = @jobId
END
The code raises the error accordingly but the problem is that I don't have any clue at all except for the unchanged field StyleID in my front end. I want my front end app to notice the error so that I can display the friendly message.
"The way to get things done is not to mind who gets the credit for doing them." - Benjamin Howett
October 7, 2002 at 4:55 am
It returns into the error collection. If using VB then do
IF ERROR RESUME NEXT or GOTO line
and if Err <> 0 then
Err.Description should contain you value.
If using C++ then it works with the TRY..CATCH method but you will need to implement a MACRO to forward the error into the catch. Not hard, ask I can provide sample.
"Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)
October 7, 2002 at 10:19 am
I removed any error handling routines and still no error reported.
That's exactly my problem. SQL Server does not report the error to VB at all.
"The way to get things done is not to mind who gets the credit for doing them." - Benjamin Howett
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply