the procedure is fine with an output (phpmyadmin)

0

How about? I have a doubt I want to make a procedure so that the end result of a result 0 or 1 according to the result number of my table users the procedure is this:

DELIMITER $$
CREATE PROCEDURE Coretec_ConfirmUser(IN p_user_mail VARCHAR(150),OUT p_result INT)
    BEGIN
        DECLARE rows INT;
        SET rows=SELECT COUNT(users.user_id) FROM users WHERE users.user_mail=p_user_mail;
        IF (rows>=1) THEN
            SET p_result=1;
        ELSE
            SET p_result=0;
        END IF;

        SELECT p_result;
    END $$
DELIMITER ;

in the end, this error votes me: Error

SQL query:

CREATE PROCEDURE Coretec_ConfirmUser (IN p_user_mail VARCHAR (150), OUT p_result INT)     BEGIN         DECLARE rows INT

MySQL has said: 1064 - Something is wrong in its syntax near '' on line 3

    
asked by emilio paredes 28.10.2018 в 00:16
source

1 answer

0

The problem I think is in the declaration of the variable and in the assignment. Please try to do it this way:

DELIMITER $$
CREATE PROCEDURE Coretec_ConfirmUser(IN p_user_mail VARCHAR(150),OUT p_result INT)
    BEGIN
        SELECT @rows = COUNT(users.user_id) FROM users WHERE users.user_mail=p_user_mail;
        IF (@rows > 0) THEN
            SET p_result=1;
        ELSE
            SET p_result=0;
        END IF;

        SELECT p_result;
    END $$
DELIMITER ;

Good luck!

    
answered by 28.10.2018 / 02:10
source