mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
47 lines
1.4 KiB
Text
47 lines
1.4 KiB
Text
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
|