像我这样是可以的:
CREATE PROCEDURE sp_add(a int, b int,out c int)
begin
set c=a+ b
end
调用过程:
call sp_add (1,2,@a)
select @a
CREATE PROCEDURE test_pro1(IN username VARCHAR(20),IN loginPwd VARCHAR(20))BEGIN
INSERT INTO admin(admin.username,PASSWORD)
VALUES(username,loginpwd)
END $
CREATE PROCEDURE test_pro2(IN id INT,OUT NAME VARCHAR(20),OUT phone VARCHAR(20))
BEGIN
SELECT b.name ,b.phone INTO NAME,phone
FROM beauty b
WHERE b.id = id
END $
CREATE PROCEDURE test_pro3(IN birth1 DATETIME,IN birth2 DATETIME,OUT result INT)
BEGIN
SELECT DATEDIFF(birth1,birth2) INTO result
END $
CREATE PROCEDURE test_pro4(IN mydate DATETIME,OUT strDate VARCHAR(50))
BEGIN
SELECT DATE_FORMAT(mydate,'%y年%m月%d日') INTO strDate
END $
CALL test_pro4(NOW(),@str)
如 传入 :小昭
返回: 小昭 AND 张无忌
DROP PROCEDURE test_pro5 $
CREATE PROCEDURE test_pro5(IN beautyName VARCHAR(20),OUT str VARCHAR(50))
BEGIN
SELECT CONCAT(beautyName,' and ',IFNULL(boyName,'null')) INTO str
FROM boys bo
RIGHT JOIN beauty b ON b.boyfriend_id = bo.id
WHERE b.name=beautyName
END $
CALL test_pro5('柳岩',@str)
DROP PROCEDURE test_pro6
CALL test_pro6(3,5)$
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)