From: --CELKO-- on
DECLARE @alert_flg CHAR(3);
SET @alert_flg = 'ALL';

then use a CASE expression in your code instead of sticking to a
procedural coding style:

CASE WHEN @alert_flg = 'ALL'
THEN -1 ELSE CAST (@alert_flg AS INTEGER) END

Casting from a string to an integer has problems.