CREATE PROCEDURE proc_borrow (IN stu_id INT, book_id IN INT, IN borrow_date DATETIME)
The BEGIN
IF func_get_integ (stu_id)=1 AND func_get_booknum (stu_id)=1 THEN
INSERT INTO borrow_table (stu_id, book_id, borrow_date)
VALUES (stu_id, book_id, borrow_date);
The ELSE
SELECT 'add failure;
END IF;
END;
Call proc_borrow process without error, but the insert data (1, 1, now ());
Adds the failure, other statement sentence by sentence test no problem, I estimate is the problem that the IF condition, a great god!
(if the two functions is to return the two data to 1 at the same time, can insert data)
CodePudding user response:
Create a stored procedure before and after any DELIMITER?CodePudding user response:
Func_get_integ (1)=1 AND func_get_booknum (1)=1You into stu_id value, can guarantee func_get_integ func_get_booknum both function return value is 1