Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE FUNCTION cdigit (s CHAR(12))
- RETURNS TINYINT UNSIGNED DETERMINISTIC
- RETURN (200 - (2*SUBSTR(s,3,1) + SUBSTR(s,4,1) + 2*SUBSTR(s,5,1) + SUBSTR(s,6,1) + 2*SUBSTR(s,7,1) + SUBSTR(s,8,1) + 2*SUBSTR(s,9,1) + SUBSTR(s,10,1) + 2*SUBSTR(s,11,1) + IF(SUBSTR(s,3,1) > 4, 1, 0) + IF(SUBSTR(s,5,1) > 4, 1, 0) + IF(SUBSTR(s,7,1) > 4, 1, 0) + IF(SUBSTR(s,9,1) > 4, 1, 0) + IF(SUBSTR(s,11,1) > 4, 1, 0))) % 10;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement