2

I need to pass a parameter for a hex color to a procedure and evaluate to make sure it is a valid hex color.

This is the regex:

select '#008000' REGEXP '^#[0-9A-F]{6}$' as `ishexcolor`;

It needs to be inserted in this procedure:

BEGIN

INSERT INTO refdata.Color(`colorCode`, `notes`)
VALUES (_colorCode, _notes);

END$$

I am new to MySQL and not familiar with the syntax. Any help?

1 Answer 1

1

Figured out the solution:

BEGIN
    IF _colorCode REGEXP '^#[0-9A-F]{6}$' = 1 THEN
        INSERT INTO refdata.Color(ColorCode, notes)
        VALUES (_colorCode, _notes);
    END IF;
END
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.