In Oracle, the RAISE_APPLICATION_ERROR procedure allows you to raise an user-defined error with the error number in the negative range from -20000 to -20999.
In MySQL, you can use the SIGNAL statement with the recommended SQLSTATE value '45000' for user-defined exceptions.
Oracle:
-- Sample procedure CREATE OR REPLACE PROCEDURE error1 IS BEGIN RAISE_APPLICATION_ERROR (-20205, 'Some error message'); END; / -- Calling the procedure CALL error1(); /* ORA-20205: Some error message */ /* ORA-06512: at "ERROR1", line 4 */
MySQL:
DROP PROCEDURE IF EXISTS error1; DELIMITER // -- Sample procedure CREATE PROCEDURE error1() BEGIN SIGNAL SQLSTATE '45205' SET MESSAGE_TEXT = 'Some error message'; END; // DELIMITER ; -- Calling the procedure CALL error1(); /* ERROR 1644 (45205): Some error message */
For more information, see Oracle to MySQL Migration.