Using EXCEPTION

How can I stop an EXCEPTION list from running?

If I have the following code:
BEGIN
   DECLARE myexception EXCEPTION
   FOR SQLSTATE '99001';
   //SIGNAL myexception;

   EXCEPTION
      WHEN myexception THEN
         MESSAGE 'My exception signaled'
         TO CLIENT;

    MESSAGE 'Last'
         TO CLIENT;
END

If I comment out the SIGNAL statement, both messages appear.
If I don't comment out the SIGNAL statement, neither appear.

How do I end an exception?

   EXCEPTION
      WHEN myexception THEN BEGIN
         MESSAGE 'My exception signaled'
         TO CLIENT;
      END;

does not appear to work.

Or does my EXCEPTION code have to always be at the end of the procedure 
block?

Basically, I want the 'Last' message to appear if SIGNAL hasn't been 
executed.  At the moment, no statements after EXCEPTION fire.

Cheers,

Shao


0
Shao
1/11/2007 4:22:06 PM
sybase.sqlanywhere.general 32637 articles. 4 followers. Follow

2 Replies
341 Views

Similar Articles

[PageSpeed] 21

Shao,

AFAIK the exception clause must be the last statement in a block (taken from
the 9.0.2 docs):
[ statement-label : ]
BEGIN [ [ NOT ] ATOMIC ]
   [ local-declaration; ... ]
   statement-list
   [ EXCEPTION [ exception-case ... ] ]
END [ statement-label ]

I guess there are two solutions:

1.
Set the
    MESSAGE 'Last'
         TO CLIENT;
after the SIGNAL statement and directly before the exception clause.
If the exception is signaled before, execution jumps over the following
statements (i.e. the "message 'last'...) so they are not called.

In this case, "Last" will only be called if the exception is not signaled.


2. Use an inner block:
BEGIN
   BEGIN
      DECLARE myexception EXCEPTION
      FOR SQLSTATE '99001';
      //SIGNAL myexception;

      EXCEPTION
         WHEN myexception THEN
            MESSAGE 'My exception signaled'
            TO CLIENT;
    END;
    MESSAGE 'Last'
         TO CLIENT;
END

In this case, "Last" will be called whether myexception is signaled or not.
(It may not be called if a different exception is called within the inner
block and there is not according exception handler and no when other
clause.)

HTH

Volker


"Shao Chan" <noemail@noemail.com> schrieb im Newsbeitrag
news:45a6723e@forums-1-dub...
> How can I stop an EXCEPTION list from running?
>
> If I have the following code:
> BEGIN
>    DECLARE myexception EXCEPTION
>    FOR SQLSTATE '99001';
>    //SIGNAL myexception;
>
>    EXCEPTION
>       WHEN myexception THEN
>          MESSAGE 'My exception signaled'
>          TO CLIENT;
>
>     MESSAGE 'Last'
>          TO CLIENT;
> END
>
> If I comment out the SIGNAL statement, both messages appear.
> If I don't comment out the SIGNAL statement, neither appear.
>
> How do I end an exception?
>
>    EXCEPTION
>       WHEN myexception THEN BEGIN
>          MESSAGE 'My exception signaled'
>          TO CLIENT;
>       END;
>
> does not appear to work.
>
> Or does my EXCEPTION code have to always be at the end of the procedure
> block?
>
> Basically, I want the 'Last' message to appear if SIGNAL hasn't been
> executed.  At the moment, no statements after EXCEPTION fire.
>
> Cheers,
>
> Shao
>
>


0
Volker
1/11/2007 4:44:42 PM
Thanks for that.  I moved the EXCEPTION statement to the end and all is 
well. :)

Cheers,

Shao


"Volker Barth" <No_VBarth@Spam_GLOBAL-FINANZ.de> wrote in message 
news:45a6778a$1@forums-1-dub...
> Shao,
>
> AFAIK the exception clause must be the last statement in a block (taken 
> from
> the 9.0.2 docs):
> [ statement-label : ]
> BEGIN [ [ NOT ] ATOMIC ]
>   [ local-declaration; ... ]
>   statement-list
>   [ EXCEPTION [ exception-case ... ] ]
> END [ statement-label ]
>
> I guess there are two solutions:
>
> 1.
> Set the
>    MESSAGE 'Last'
>         TO CLIENT;
> after the SIGNAL statement and directly before the exception clause.
> If the exception is signaled before, execution jumps over the following
> statements (i.e. the "message 'last'...) so they are not called.
>
> In this case, "Last" will only be called if the exception is not signaled.
>
>
> 2. Use an inner block:
> BEGIN
>   BEGIN
>      DECLARE myexception EXCEPTION
>      FOR SQLSTATE '99001';
>      //SIGNAL myexception;
>
>      EXCEPTION
>         WHEN myexception THEN
>            MESSAGE 'My exception signaled'
>            TO CLIENT;
>    END;
>    MESSAGE 'Last'
>         TO CLIENT;
> END
>
> In this case, "Last" will be called whether myexception is signaled or 
> not.
> (It may not be called if a different exception is called within the inner
> block and there is not according exception handler and no when other
> clause.)
>
> HTH
>
> Volker
>
>
> "Shao Chan" <noemail@noemail.com> schrieb im Newsbeitrag
> news:45a6723e@forums-1-dub...
>> How can I stop an EXCEPTION list from running?
>>
>> If I have the following code:
>> BEGIN
>>    DECLARE myexception EXCEPTION
>>    FOR SQLSTATE '99001';
>>    //SIGNAL myexception;
>>
>>    EXCEPTION
>>       WHEN myexception THEN
>>          MESSAGE 'My exception signaled'
>>          TO CLIENT;
>>
>>     MESSAGE 'Last'
>>          TO CLIENT;
>> END
>>
>> If I comment out the SIGNAL statement, both messages appear.
>> If I don't comment out the SIGNAL statement, neither appear.
>>
>> How do I end an exception?
>>
>>    EXCEPTION
>>       WHEN myexception THEN BEGIN
>>          MESSAGE 'My exception signaled'
>>          TO CLIENT;
>>       END;
>>
>> does not appear to work.
>>
>> Or does my EXCEPTION code have to always be at the end of the procedure
>> block?
>>
>> Basically, I want the 'Last' message to appear if SIGNAL hasn't been
>> executed.  At the moment, no statements after EXCEPTION fire.
>>
>> Cheers,
>>
>> Shao
>>
>>
>
> 


0
Shao
1/12/2007 10:22:21 AM
Reply:

Similar Artilces:

3.12 Scheduler Exception, General Exception
3.12 is running successfully.  However I am getting errors in the log.  I show both below.   Any suggeestions?   General Exception: AssemblyVersion: -1Method: FileName: FileLineNumber: -1FileColumnNumber: -1PortalID: -1PortalName: UserID: -1UserName: ActiveTabID: -1ActiveTabName: AbsoluteURL: AbsoluteURLReferrer: ExceptionGUID: DefaultDataProvider: InnerException: Object reference not set to an instance of an object.Message: System.NullReferenceException: Object reference not set to an instance of an object. at DotNetNuke.Entities.Users.UserController.FillUserInfo(ID...

Please Help : An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception
 Hi , I've an ASP.NET 2.0 web site working with SQL Server 2005 Database and IIS 5 When I try to accesss the web site from any other PC and access a web form calling a database i got this error. Please Help Server Error in '/HSEWebUI' Application. Login failed for user 'AA\ASPNET'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'AA\ASPNET'.Source Error:...

GENERAL EXCEPTION! Exception of type System.OutOfMemoryException was thrown.
Hi.  I'm getting a GENERAL EXCEPTION! Exception of type System.OutOfMemoryException was thrown.  My app  was written in ASP.Net 1.1.4322 and C#.  It is running under IIS 6.0 under it's own app pool.  This is a live PRODUCTION issue.  This used to work.  Now it doesn't.  There are other ASP.Net apps running on this box, but they all have their own app pool.  This app uses Microsoft Enterprise Library and the Data Access Application Block to access a remote SQL Server to perform a data insertion.  Here's a scenario: Reboot the b...

Use in general
Name: Roques Julien Product: Firefox Release Candidate Summary: Use in general Comments: Sometime, the mozilla bugs and stops or is frozen. This problem appears more frequently when I try to read some PDFs. Another problem is that some videos do not work properly. Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9) Gecko/2008051206 Firefox/3.0 From URL: http://hendrix.mozilla.org/ ...

Use of Categories | General "Real" World Uses
I've been using the Firebird extension of the Mozilla Calendar and I like it better than my use of Outlook 2000 in terms of layout and open standard file format. Much thanks to the people who keep this project moving forward. I read somewhere in bugzilla (on the topic of Categories) that the first priority was to get Category functionality working, and then MAYBE think about implementing the ability to assign multiple categories to a single task/appointment/et cetera (whatever the proper nomenclature is for dated items input by the user and acted upon as an "object&qu...

What generals generally do
Reading a McChrystal thread elsewhere, I came across someone quoting a US general http://en.wikipedia.org/wiki/Smedley_Butler > I spent 33 years and four months in active military service and > during that period I spent most of my time as a high class thug for > Big Business, for Wall Street and the bankers. In short, I was a > racketeer, a gangster for capitalism. I helped make Mexico and > especially Tampico safe for American oil interests in 1914. I helped > make Haiti and Cuba a decent place for the National City Bank boys to > collect revenues in. I ...

the general use
Name: Pilko Nera Product: Firefox Summary: the general use Comments: I thinks IE8 is much better than Firefox 3.1 Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.1b3) Gecko/20090305 Firefox/3.1b3 From URL: http://hendrix.mozilla.org/ Note to readers: Hendrix gives no expectation of a response to this feedback but if you wish to provide one you must BCC (not CC) the sender for them to see it. ...

Using Exceptions
Hi, I've read that exceptions should only be used to catch exceptional occurences because they're slow. However, is this true also for just using a 'finally' block. If there's no exception thrown or caught, is using a 'finally' block a performance hit? Cheers, WT. Web dev - spending forever achieving nothing. You can't use a Finally block without a matching Try block. And the performance hit occurs before the Try/Catch code is executed. It is related to how .NET packages up code that is within a Try/Catch block, before its execution. You've read that Try/Catch exception ...

System.IO Exception
Hi, I've created a page where a user can upload a zip file of images and display the list, the HTML list includes a thumbnail of the image eg: "<img src="thumb.aspx?p=blah">". To keep the thumbnail images seperate to the working directories for the unzipping/storage processes; A folder "temp" is used within the users directory. Whenever the thumb.aspx page is used, the image is copied from the "unzipped" directory to the "temp" directory, and the thumb is created using the "temp" directory as the source.The problem is on irregular occasions after debugging a system.IO.excepti...

When to use ( and when to use ((?
I'm just not getting it. When do you use ( in a statement, when do you need to use ((, and is the space after either or both mandatory? For example, I coded this statement: if (( $_ eq $bad_guys_ip )) { more_stuff_here }; Why the two (( in an if? And why does it seem to not work when I miss the space after the ((? Thanx! Mark me as... /Corn-fused|Dense/ > I'm just not getting it. >=20 > When do you use ( in a statement, when do you need to use ((, and is > the space after either or both mandatory? >=20 > For example, I coded this sta...

general use
Name: Taber Email: kwtaberathotmaildotcom Product: Firefox Summary: general use Comments: too click happy. too many button operations to use easily. Now I have to ask how to delete it from my machine as there is no uninstall button on the bar Browser Details: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.2) Gecko/20100316 Firefox/3.6.2 (.NET CLR 3.5.30729) From URL: http://hendrix.mozilla.org/ Note to readers: Hendrix gives no expectation of a response to this feedback but if you wish to provide one you must BCC (not CC) the sender for them to see it. ...

Using Using
I have just completed reading a chapter in my book on performance. The books says to speed up performance on your web site you should use the using statement when opening connections. My question is how do you catch errors if you are using this as apposed to a try catch block.thanksBryan  Why would you use it as an alternative to a try/catch statement. Couldn't you just do something like  public void UsingSomeMethod() { try { SomeMethod(); } catch(SomeException e) { /// do something useful }}public void SomeMethod() { using (Something) { ...

An exceptional exception
I'm getting an exception in the exceptions.vb class. When an exception is caught:Catch exc As Exception 'Module failed to load ProcessModuleLoadException(Me, exc) End Tryline 103 of the exceptions.vb file:Public Sub ProcessModuleLoadException(ByVal ctrlModule As PortalModuleControl, ByVal exc As Exception) ProcessModuleLoadException("Error: " + ctrlModule.ModuleConfiguration.ModuleTitle + " is currently unavailable.", ctrlModule, exc, True) End Sub throws an error because it cannot get the moduleTitle from the "Me" (PortalModuleControl) argu...

Exceptional Exception...
I am getting the following exception when people inside my company go to our new CSK derived site... Server Error in '/' Application. -------------------------------------------------------------------------------- The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly. Requested Url: /About+Us/Technical+Questions/default.aspx -------------------------------...

Web resources about - Using EXCEPTION - sybase.sqlanywhere.general

United States free speech exceptions - Wikipedia, the free encyclopedia
Exceptions to free speech in the United States are limitations on the First Amendment's guarantee of free speech and expression as recognized ...

Podcast #42 – It’s The Exception That Proves The Rule
... Language and Usage , which was frustrated by the high number of certain types of questions that were coming in. Is this podcast the exception ...

Paul Ryan - Mother's health exception to abortion is "Mack truck" sized loophole - YouTube
April 5, 2000 - During the debate on a partial-birth abortion ban, Paul Ryan says that "the [mother's] health exception is a loophole wide enough ...

Why Kevin Pietersen is the exception to the No Dickhead Rule
Something fascinating is going on in English cricket at the moment.

Exception to Origin rule
Exception to Origin rule

India becomes the exception to US nuclear ban
President George Bush has agreed to share civilian nuclear technology with India, reversing decades of US policies designed to discourage countries ...

Is Richard Umbers, Bernie Brookes' replacement as Myer CEO, an exception?
Myer's CIO was recently elevated to the top job, but he's in a very small minority.

Men Need to Admit That Jian Ghomeshi Is No Exception
That men like Jian Ghomeshi are a terrible exception and if we as men simply stand up and say we are not as bad as that, or that we are not rapists ...

No exception in punishing the corrupt: People's Daily
No exception in punishing the corrupt: People's Daily People's Daily Online BEIJING, June 30 People's Daily , the flagship newspaper of the ...

No exception allowed in graft crackdown: People's Daily
No exception allowed in graft crackdown: People's Daily - Ecns.cn ecns The expulsion of Ling Jihua from the Communist Party of China (CPC) ...

Resources last updated: 12/29/2015 7:45:34 AM