blob: 50e6b1cc61cfe4bb5a7c1de3a4ee985660c13af9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
CREATE TABLE t1 (id INT);
DELIMITER $$;
CREATE PROCEDURE proc1 (OUT cnt INT) COMMENT 'comment1' BEGIN SELECT COUNT(*) INTO cnt FROM t1; END$$
DELIMITER ;$$
CALL proc1(@cnt);
SELECT @cnt;
INSERT INTO t1 VALUES (1), (2), (3);
CALL proc1(@cnt);
SELECT @cnt;
DELIMITER $$;
--error ER_SP_ALREADY_EXISTS
CREATE PROCEDURE proc1 (OUT cnt INT) COMMENT 'comment2'
BEGIN SELECT COUNT(*) INTO cnt FROM t1; END$$
SELECT comment FROM mysql.proc WHERE name='proc1'$$
CREATE PROCEDURE IF NOT EXISTS proc1 (OUT cnt INT) COMMENT 'comment3'
BEGIN SELECT COUNT(*) INTO cnt FROM t1; END$$
SELECT comment FROM mysql.proc WHERE name='proc1'$$
--error ER_WRONG_USAGE
CREATE OR REPLACE PROCEDURE IF NOT EXISTS proc1 (OUT cnt INT) COMMENT 'comment4'
BEGIN SELECT COUNT(*) INTO cnt FROM t1; END$$
SELECT comment FROM mysql.proc WHERE name='proc1'$$
CREATE OR REPLACE PROCEDURE proc1 (OUT cnt INT) COMMENT 'comment5'
BEGIN SELECT COUNT(*) INTO cnt FROM t1; END$$
SELECT comment FROM mysql.proc WHERE name='proc1'$$
DELIMITER ;$$
DROP PROCEDURE proc1;
DELIMITER $$;
CREATE PROCEDURE IF NOT EXISTS proc1 (OUT cnt INT) BEGIN SELECT COUNT(*) INTO cnt FROM t1; END$$
DELIMITER ;$$
INSERT INTO t1 VALUES (1), (2), (3);
CALL proc1(@cnt);
SELECT @cnt;
DROP TABLE IF EXISTS t1;
DROP PROCEDURE IF EXISTS proc1;
DROP PROCEDURE IF EXISTS proc1;
|