I need to write SQL script which stops if some values not found in DB. Something like this (pseudo-code):
BEGIN;
...
set @a = (select ... );
if @a IS NULL THEN STOP_WITH_ERROR_AND_ROLLBACK();
...
COMMIT;
Can anybody help to me?
UPDATE: for some reasons, I can't use stored procedures or functions.
UPDATE 2: Note: I don't need explicit rollback. Break of script execution are sufficiently. It automatically rollback changes of not-committed transaction.
DECLARE EXIT HANDLER FOR NOT FOUND...; see here which can execute a specific code you may need before exiting. You are saying that you cannot use a stored procedure/function. Could you explain why?