MySQL Forums
Forum List  »  Triggers

Re: How to Raise Error ?
Posted by: William Chiquito
Date: December 19, 2006 07:53PM

Hi Roland,

Very good your solution.

That you think of a solution like this:

DELIMITER $$

DROP PROCEDURE IF EXISTS `MyRaiseError`$$

CREATE PROCEDURE `MyRaiseError`(msg VARCHAR(62))
BEGIN
DECLARE Tmsg VARCHAR(80);
SET Tmsg = msg;
IF (CHAR_LENGTH(TRIM(Tmsg)) = 0 OR Tmsg IS NULL) THEN
SET Tmsg = 'ERROR GENERADO';
END IF;
SET Tmsg = CONCAT('@@MyError', Tmsg, '@@MyError');
SET @MyError = CONCAT('INSERT INTO', Tmsg);
PREPARE stmt FROM @MyError;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
END$$

DELIMITER ;

mysql> call MyRaiseError('Here error message!');
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '@@MyE
rrorHere error message!@@MyError' at line 1

You will always have he himself message of error with the string of error between “@@MyError”. The idea is that soon you clean to the string being single the error message.

It is not the best solution but the declaration of the UDF with the DLL is avoided.

What you think? thanks.

Options: ReplyQuote


Subject
Views
Written By
Posted
25203
November 17, 2005 04:00AM
16796
November 17, 2005 06:58AM
23755
November 19, 2005 08:53AM
14576
February 23, 2006 02:28AM
10847
February 23, 2006 04:42AM
15539
February 24, 2006 08:28AM
8544
February 24, 2006 10:15AM
6327
February 24, 2006 12:42PM
7948
February 27, 2006 08:56AM
6742
February 27, 2006 11:27AM
18946
February 28, 2006 05:22AM
6598
December 20, 2006 03:34AM
4151
November 18, 2008 08:28AM
4807
November 18, 2008 12:45PM
6233
December 19, 2006 11:00AM
5040
December 19, 2006 02:35PM
Re: How to Raise Error ?
6279
December 19, 2006 07:53PM
4456
December 20, 2006 03:37AM
4671
December 19, 2006 11:01AM
5550
November 24, 2006 05:32AM
4527
November 24, 2006 07:02AM
3660
December 23, 2008 06:08AM
11291
February 25, 2006 11:48PM
4995
December 19, 2007 04:24AM
3974
December 24, 2008 01:02PM
4808
December 19, 2007 03:59AM
4676
December 19, 2007 05:09AM
3567
November 18, 2008 08:25AM
3953
November 18, 2008 12:49PM
6060
December 19, 2007 04:46AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.