Three types of exceptions can occur:
What Is an Exception?
An exception is simply a message that is generated when an error occurs.
All of the predefined exceptions —SQLCODE and GDSCODE —have text messages associated with them. The default messages are in English, but they don’t have to be. Versions of the messages are available in a few other languages (including pig Latin!), while others are either “works in progress” or “jobs waiting for volunteers.”
Firebird has DDL syntax for creating custom exceptions with text messages up to 78 bytes long. In Firebird 1.5, you can extend your custom exceptions at runtime and replace the text, including context-specific details, to the message that goes back across the wire.
Creating an Exception
Creating an exception is one of the simplest pieces of DDL in the lexicon. The syntax isCREATE EXCEPTION exception-name <message>;
exception-name is a regular Firebird identifier of 31 characters or less. It must be unique among identifiers for exceptions and, in dialect 3, it can be double quoted and case sensitive.
<message> is a single-quoted string of text in character set NONE. The text is necessarily terse because of the length limit. For example:CREATE EXCEPTION NO_DOGS 'No dogs allowed!';
A CREATE EXCEPTION statement needs to be committed, just as any other DDL statement does.
Altering or Dropping an Exception
As SYSDBA or the owner of an exception that is used in stored procedures, you can alter or drop it at any time. If it is used in a trigger, it can only be altered and then only to change the text message. No dependencies are stored for exceptions used by stored procedures. This makes it a problem if you drop one and forget to replace it—it is embarrassing to have an exception occur because of a missing exception!
To drop our NO_DOGS exception:DROP EXCEPTION NO_DOGS;
To alter it:ALTER EXCEPTION NO_DOGS 'No dogs allowed except Irish Wolfhounds!';
Firebird Related Interview Questions
|RDBMS Interview Questions||MySQL Interview Questions|
|Linux Interview Questions||Mac OS X Deployment Interview Questions|
|Windows Administration Interview Questions||Windows Server 2003 Interview Questions|
|SQL Interview Questions||NoSQL Interview Questions|
|Advanced C++ Interview Questions|
All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.