473,653 Members | 3,000 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Exceptions in Triggers MYSQL 5.0

1 New Member
Hi,

Someone knows about. How can i create exceptions or display messages in triggers, as the commands "raiserror" and "Print" in sqlserver ?

Thanks,

Olimpio.
Aug 22 '06 #1
1 2941
masdi2t
37 New Member
u can create exception's like behaviour with handler but i do not understand how to display message.

this one from MySQL documentation
Expand|Select|Wrap|Line Numbers
  1. DECLARE handler_type HANDLER FOR condition_value[,...] statement
  2.  
  3. handler_type:
  4.     CONTINUE
  5.   | EXIT
  6.   | UNDO
  7.  
  8. condition_value:
  9.     SQLSTATE [VALUE] sqlstate_value
  10.   | condition_name
  11.   | SQLWARNING
  12.   | NOT FOUND
  13.   | SQLEXCEPTION
  14.   | mysql_error_code
  15.  
also from MySQL documentation
Expand|Select|Wrap|Line Numbers
  1. mysql> CREATE TABLE test.t (s1 int,primary key (s1));
  2. Query OK, 0 rows affected (0.00 sec)
  3.  
  4. mysql> delimiter //
  5.  
  6. mysql> CREATE PROCEDURE handlerdemo ()
  7.     -> BEGIN
  8.     ->   DECLARE CONTINUE HANDLER FOR SQLSTATE '23000' SET @x2 = 1;
  9.     ->   SET @x = 1;
  10.     ->   INSERT INTO test.t VALUES (1);
  11.     ->   SET @x = 2;
  12.     ->   INSERT INTO test.t VALUES (1);
  13.     ->   SET @x = 3;
  14.     -> END;
  15.     -> //
  16. Query OK, 0 rows affected (0.00 sec)
  17.  
Aug 23 '06 #2

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

Similar topics

33
2991
by: Steven Bethard | last post by:
I feel like this has probably been answered before, but I couldn't find something quite like it in the archives. Feel free to point me somewhere if you know where this has already been answered. I have a list in a particular order that I want to split into two lists: the list of every nth item, and the list of remaining items. It's important to maintain the original order in both lists. So the first list is simple:
2
1769
by: Paul Reddin | last post by:
Hi, I've implemented calling a SP form a trigger using the CALL_PROCEDURE() UDF from http://www-106.ibm.com/developerworks/db2/library/techarticle/dm-0402greenstein/ A couple of questions remain for future considerations? 1. This mechanism desn't allow for exceptions/return codes from the
10
1293
by: Razzie | last post by:
Hi all, The title of this post may sound a bit weird, but I was wondering about the following nonetheless. I have a class libray containing, say, 4 classes: A, B, C, D. Class A somehow has a reference to B, B has a reference to C, and C to D. If an exception happens in class D, I would like class A to get a notification of this (all execution on classes B to D should be terminated). I am wondering how to do this. The following seems...
7
6108
by: JJ | last post by:
How do I set one field to have the updated timestamp, and another to have the created timestamp? I want to do this directly from code generated from DB Designer if possible?! JJ
1
4836
by: krunalb | last post by:
Hi, As I understand STL are bound to throw an exception on occurrence of invalid condition. Is there a way in which I can use -fno-exceptions with STL. (Something similar to new(nothrow) Regards, Krunal
2
1290
by: maheshmurali | last post by:
Can Mysql Support VIew, Triggers, Cursors? If possible, Do all versions of Mysql support the above?
2
1122
by: paulq182 | last post by:
hello, im new to mysql and was looking to know what triggers are? cheers!!!
0
1713
by: imran haq | last post by:
Hi All, I have 3 rather Long Questions that are causing alot of trouble: I would appreciate all the help i can get and tried to use A post sent to atli in the past but it did not help... !) I have an events table, within the events table I have 7 columns, Alias varchar (30) Progress int(1) Val double Stamp timestamp
4
5732
by: --CELKO-- | last post by:
I need to convert a bunch of DB2 triggers to Oracle. Is there any kind of tools for this?
0
8370
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8811
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8470
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7302
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6160
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4147
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4291
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1914
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1591
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.