Okey tried to find something that solved my problem but everyone else seem to have this inside the procedure and not when they are calling this. Guess I'm unique..
So I have created this procedure
USE `DB`;
DROP procedure IF EXISTS `NAME`;
DELIMITER $$
USE `DB`$$
CREATE PROCEDURE `NAME` (IN arg1 INT,IN arg2 INT, OUT arg3 varchar(10))
BEGIN
UPDATE T1 SET var1 = arg1 WHERE var2 = arg2 ;
IF((SELECT var2 FROM T1 WHERE var2 = arg2) IS NOT NULL) THEN
SET arg3 = "YEAH!!";
COMMIT;
ELSE
SET arg3 = "FAIL!!";
ROLLBACK;
END IF;
END$$
DELIMITER ;
And I'm now trying to call for the procedure using this code
SET @arg1 = 1, @arg2 = 2;
CALL `DB`.`NAME`(@arg1, @arg2, @arg3);
SELECT @arg3;
And i'm getting this error
Error Code: 1241. Operand should contain 1 column(s)
Would love if someone with a brighter mind than me could explain what I'm doing wrong.
EDIT: Found out what it was! The IF statement shouldn't be surrounded by ()
IF (SELECT var2 FROM T1 WHERE var2 = arg2) IS NOT NULL THEN
SET arg3 = "YEAH!!";
COMMIT;
Do this and it will work!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.