473,473 Members | 2,178 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

capturing object not found in SP

13 New Member
For the following SP, is table aaa doesn't exist, error is not caught. Any help is appreciated. Thanks.
I would still expect ''Unexpected error occurred!' if table 'aa' doesn't exist.
I am using 2005.

DECLARE @intErrorCode INT

BEGIN TRAN
UPDATE aa
SET DRE_EMAIL_ADDR = 'ss'
WHERE DRE_EMAIL_ADDR = 'mm'

SELECT @intErrorCode = @@ERROR
IF (@intErrorCode <> 0) GOTO PROBLEM
COMMIT TRAN

PROBLEM:
IF (@intErrorCode <> 0) BEGIN
PRINT 'Unexpected error occurred!'
ROLLBACK TRAN
END

Also same results with TRY/CATCH
It's still not get caught.
It doesn't display "Should be here ...." but just :
Msg 208, Level 16, State 1, Line 3
Invalid object name 'aa'.
And I am using 2005.


BEGIN TRY
BEGIN Transaction
UPDATE aa SET DRE_EMAIL_ADDR = 'ss' WHERE DRE_EMAIL_ADDR = 'mm'
COMMIT Transaction
END TRY
BEGIN CATCH
DECLARE @err int
SELECT @err = @@error
PRINT 'Should be here : @@error: ' + ltrim(str(@err))
ROLLBACK
END CATCH
Apr 17 '08 #1
1 1744
ck9663
2,878 Recognized Expert Specialist
For the following SP, is table aaa doesn't exist, error is not caught. Any help is appreciated. Thanks.
I would still expect ''Unexpected error occurred!' if table 'aa' doesn't exist.
I am using 2005.

DECLARE @intErrorCode INT

BEGIN TRAN
UPDATE aa
SET DRE_EMAIL_ADDR = 'ss'
WHERE DRE_EMAIL_ADDR = 'mm'

SELECT @intErrorCode = @@ERROR
IF (@intErrorCode <> 0) GOTO PROBLEM
COMMIT TRAN

PROBLEM:
IF (@intErrorCode <> 0) BEGIN
PRINT 'Unexpected error occurred!'
ROLLBACK TRAN
END

Also same results with TRY/CATCH
It's still not get caught.
It doesn't display "Should be here ...." but just :
Msg 208, Level 16, State 1, Line 3
Invalid object name 'aa'.
And I am using 2005.


BEGIN TRY
BEGIN Transaction
UPDATE aa SET DRE_EMAIL_ADDR = 'ss' WHERE DRE_EMAIL_ADDR = 'mm'
COMMIT Transaction
END TRY
BEGIN CATCH
DECLARE @err int
SELECT @err = @@error
PRINT 'Should be here : @@error: ' + ltrim(str(@err))
ROLLBACK
END CATCH
I think the reason is because TAC (Try and Catch) does not handle syntax or recompilation errors that prevents a batch from executing. If you use a dynamic query, it will catch it. Or put it in some other SP. Get more details here

-- CK
Apr 17 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Oz | last post by:
This is long. Bear with me, as I will really go through all the convoluted stuff that shows there is a problem with streams (at least when used to redirect stdout). The basic idea is that my...
3
by: Greg | last post by:
I want to be able to capture the user pressing Ctrl+S. I know that the IE browser has a key binding for Ctrl+S but is there any way that I can be notified of this key press anyway. I have found...
33
by: Joerg Schuster | last post by:
Hello, Python regular expressions must not have more than 100 capturing groups. The source code responsible for this reads as follows: # XXX: <fl> get rid of this limitation! if...
14
by: Brent Burkart | last post by:
I am trying to capture the Windows Authenticated username, but I want to be able to capture the login name that exists in IIS, not Windows. In order to enter my company's intranet through the...
2
by: Stampede | last post by:
Hi guys & girls, I would like to write some kind of "Head-Tracking-Software", which uses a WebCam to react to the movement of the head of the person sitting in front of the monitor. I searched...
6
by: Ed Leafe | last post by:
I've been approached by a local business that has been advised that they need to start capturing and archiving their instant messaging in order to comply with Sarbanes-Oxley. The company is largely...
3
by: rajibnsu | last post by:
While searching for capturing video with a webcam I god the following code.It gives two errors.Says:The type or namespace name 'WebcamEventArgs' does not exit in the namespace 'WebCam_Capture' (are...
1
by: - Electronic.HR - | last post by:
So, my problem is that i have to get picture from this site (the one with code on it), but I can't figure out how to do that. Picture is generated from php code, and I can't find way to save that...
2
by: GS | last post by:
How can one avoid capturing leading empty or blank lines? the data I deal with look like this "will be paid on the dates you specified. xyz supplier amount: $100.52 when: September 07,...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.