blob: 02c71ab6446a6075fd6bbe6befb9938aae9823de (
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
42
43
44
45
46
47
|
CREATE TABLE t1 (id INT);
CREATE PROCEDURE proc1 (OUT cnt INT) COMMENT 'comment1' BEGIN SELECT COUNT(*) INTO cnt FROM t1; END$$
CALL proc1(@cnt);
SELECT @cnt;
@cnt
0
INSERT INTO t1 VALUES (1), (2), (3);
CALL proc1(@cnt);
SELECT @cnt;
@cnt
3
CREATE PROCEDURE proc1 (OUT cnt INT) COMMENT 'comment2'
BEGIN SELECT COUNT(*) INTO cnt FROM t1; END$$
ERROR 42000: PROCEDURE proc1 already exists
SELECT comment FROM mysql.proc WHERE name='proc1'$$
comment
comment1
CREATE PROCEDURE IF NOT EXISTS proc1 (OUT cnt INT) COMMENT 'comment3'
BEGIN SELECT COUNT(*) INTO cnt FROM t1; END$$
Warnings:
Note 1304 PROCEDURE proc1 already exists
SELECT comment FROM mysql.proc WHERE name='proc1'$$
comment
comment1
CREATE OR REPLACE PROCEDURE IF NOT EXISTS proc1 (OUT cnt INT) COMMENT 'comment4'
BEGIN SELECT COUNT(*) INTO cnt FROM t1; END$$
ERROR HY000: Incorrect usage of OR REPLACE and IF NOT EXISTS
SELECT comment FROM mysql.proc WHERE name='proc1'$$
comment
comment1
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'$$
comment
comment5
DROP PROCEDURE proc1;
CREATE PROCEDURE IF NOT EXISTS proc1 (OUT cnt INT) BEGIN SELECT COUNT(*) INTO cnt FROM t1; END$$
INSERT INTO t1 VALUES (1), (2), (3);
CALL proc1(@cnt);
SELECT @cnt;
@cnt
6
DROP TABLE IF EXISTS t1;
DROP PROCEDURE IF EXISTS proc1;
DROP PROCEDURE IF EXISTS proc1;
Warnings:
Note 1305 PROCEDURE test.proc1 does not exist
|