lundi 7 décembre 2015

Display Present if Row exists, display Missing if otherwise

My code below checks if a row is returned. If true, it should display 'PRESENT' ELSE 'MISSING'.

I have tried values that will return either 0 or 1 but both returns 'MISSING'. What could I have missed here.

DELIMITER //

CREATE PROCEDURE UserCheck (
    IN p_ACCEPTED_BY VARCHAR(32))
BEGIN
    DECLARE isPresent INT(10);

SELECT EXISTS (
    SELECT *
    FROM ETOOLS.UserTermsAndConditions
    WHERE ACCEPTED_BY = 'p_ACCEPTED_BY') INTO isPresent;

    IF isPresent = 1 THEN
        SELECT 'PRESENT';
    ELSE
        SELECT 'MISSING';
    END IF;

END //

DELIMITER ;

Thanks, Dave

Aucun commentaire:

Enregistrer un commentaire