How to conditionally raise an error in MySQL without stored procedure
11
votes
1
answer
6839
views
I need to conditionally raise an error, but I can only use a simple statement and no stored procedure.
I'd like to do something like this:
select case when foo = "bar" then 1 else SIGNAL SQLSTATE 'ERROR' end;
Unfortunately SIGNAL is only usable in triggers and procedures and I have to use this within an existing application that only allows me to enter statements, but not procedures. (I only have one long line and no way to set a DELIMITER etc.)
Is there any other way to conditionally cause a runtime error ?
Asked by Gene Vincent
(222 rep)
Oct 7, 2014, 03:24 PM
Last activity: May 15, 2023, 11:24 AM
Last activity: May 15, 2023, 11:24 AM