Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDEV-10839 sql_mode=ORACLE: Predefined exceptions: TOO_MANY_ROWS, NO_…
…DATA_FOUND, DUP_VAL_ON_INDEX
- Loading branch information
Alexander Barkov
committed
Apr 5, 2017
1 parent
c2c45c5
commit ccb91eb
Showing
5 changed files
with
160 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
SET sql_mode=ORACLE; | ||
# | ||
# sql_mode=ORACLE: Predefined exceptions: TOO_MANY_ROWS, NO_DATA_FOUND, DUP_VAL_ON_INDEX | ||
# | ||
# | ||
# Testing NO_DATA_FOUND and TOO_MANY_ROWS | ||
# | ||
CREATE TABLE t1 (a INT); | ||
INSERT INTO t1 VALUES (10),(20); | ||
CREATE PROCEDURE p1(lim INT, res OUT VARCHAR) | ||
AS | ||
a INT; | ||
BEGIN | ||
SELECT a INTO a FROM t1 LIMIT lim; | ||
EXCEPTION | ||
WHEN TOO_MANY_ROWS THEN res:='--- too_many_rows cought ---'; | ||
WHEN NO_DATA_FOUND THEN res:='--- no_data_found cought ---'; | ||
END; | ||
$$ | ||
SET @res=''; | ||
CALL p1(0, @res); | ||
SELECT @res; | ||
@res | ||
--- no_data_found cought --- | ||
CALL p1(2, @res); | ||
SELECT @res; | ||
@res | ||
--- too_many_rows cought --- | ||
DROP PROCEDURE p1; | ||
DROP TABLE t1; | ||
# | ||
# Testing DUP_VAL_ON_INDEX | ||
# | ||
CREATE TABLE t1 (a INT PRIMARY KEY); | ||
CREATE PROCEDURE p1(res OUT VARCHAR) | ||
AS | ||
BEGIN | ||
INSERT INTO t1 VALUES (10); | ||
INSERT INTO t1 VALUES (10); | ||
EXCEPTION | ||
WHEN DUP_VAL_ON_INDEX THEN res:='--- dup_val_on_index cought ---'; | ||
END; | ||
$$ | ||
SET @res=''; | ||
CALL p1(@res); | ||
SELECT @res; | ||
@res | ||
--- dup_val_on_index cought --- | ||
SELECT * FROM t1; | ||
a | ||
10 | ||
DROP PROCEDURE p1; | ||
DROP TABLE t1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
SET sql_mode=ORACLE; | ||
|
||
--echo # | ||
--echo # sql_mode=ORACLE: Predefined exceptions: TOO_MANY_ROWS, NO_DATA_FOUND, DUP_VAL_ON_INDEX | ||
--echo # | ||
|
||
--echo # | ||
--echo # Testing NO_DATA_FOUND and TOO_MANY_ROWS | ||
--echo # | ||
|
||
CREATE TABLE t1 (a INT); | ||
INSERT INTO t1 VALUES (10),(20); | ||
DELIMITER $$; | ||
CREATE PROCEDURE p1(lim INT, res OUT VARCHAR) | ||
AS | ||
a INT; | ||
BEGIN | ||
SELECT a INTO a FROM t1 LIMIT lim; | ||
EXCEPTION | ||
WHEN TOO_MANY_ROWS THEN res:='--- too_many_rows cought ---'; | ||
WHEN NO_DATA_FOUND THEN res:='--- no_data_found cought ---'; | ||
END; | ||
$$ | ||
DELIMITER ;$$ | ||
SET @res=''; | ||
CALL p1(0, @res); | ||
SELECT @res; | ||
CALL p1(2, @res); | ||
SELECT @res; | ||
DROP PROCEDURE p1; | ||
DROP TABLE t1; | ||
|
||
--echo # | ||
--echo # Testing DUP_VAL_ON_INDEX | ||
--echo # | ||
|
||
CREATE TABLE t1 (a INT PRIMARY KEY); | ||
DELIMITER $$; | ||
CREATE PROCEDURE p1(res OUT VARCHAR) | ||
AS | ||
BEGIN | ||
INSERT INTO t1 VALUES (10); | ||
INSERT INTO t1 VALUES (10); | ||
EXCEPTION | ||
WHEN DUP_VAL_ON_INDEX THEN res:='--- dup_val_on_index cought ---'; | ||
END; | ||
$$ | ||
DELIMITER ;$$ | ||
SET @res=''; | ||
CALL p1(@res); | ||
SELECT @res; | ||
SELECT * FROM t1; | ||
DROP PROCEDURE p1; | ||
DROP TABLE t1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters