Sunday, December 20, 2009

Generate token procedure


CREATE PROCEDURE GenerateToken(v_email varchar(255))
BEGIN
DECLARE i_count INT;
SELECT COUNT(email) INTO i_count
FROM tbToken WHERE email = v_email;

IF (i_count > 0) THEN
UPDATE tblToken
SET token = UUID(),
created_date = NOW()
WHERE email = v_email;
ELSE
INSERT INTO tblToken(email, token, created_date)
VALUES(v_email, UUID(), NOW());
END IF;
END;

No comments:

Post a Comment

Oracle Query