- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to raise an error within MySQL?
MySQL has introduced signals similar to an exception in other languages. Let us first see the syntax of signal.
SIGNAL SQLSTATE ' PredefinedValueforSignalError' SET MESSAGE_TEXT = 'AnyMessageInformation';
Above, we have set our own error message text as well.
We will apply the above query to get an error message with the help of signals.
mysql > SIGNAL SQLSTATE '42927' SET MESSAGE_TEXT = 'Error Generated';
The following is the output of the above query.
ERROR 1644 (42927): Error Generated
In the above output, ‘42927’ is a SQLSTATE and ‘Error Generated’ is an error message, which we added.
Advertisements