Details
- 
     Technical task Technical task
- 
    Status: Closed (View Workflow)
- 
    Major 
- 
    Resolution: Fixed
- 
    10.3(EOL)
- 
        10.2.2-3, 10.2.2-1, 10.2.2-2, 10.2.2-4, 10.1.18
Description
This is similar to MDEV-12098, but for cursors with parameters.
The below script demonstrates using of a FOR loop with a cursor cur that has two parameters.
| DROP TABLE IF EXISTS t1; | 
| DROP PROCEDURE IF EXISTS p1; | 
| SET sql_mode=ORACLE; | 
| CREATE TABLE t1 (a INT, b VARCHAR(32)); | 
| INSERT INTO t1 VALUES (10,'b0'); | 
| INSERT INTO t1 VALUES (11,'b1'); | 
| INSERT INTO t1 VALUES (12,'b2'); | 
| DELIMITER $$ | 
| CREATE PROCEDURE p1(pa INT, pb VARCHAR(32)) AS | 
| CURSOR cur(va INT, vb VARCHAR(32)) IS | 
| SELECT a, b FROM t1 WHERE a=va AND b=vb; | 
| BEGIN | 
| FOR rec IN cur(pa,pb) | 
|   LOOP | 
| SELECT rec.a, rec.b; | 
| END LOOP; | 
| END; | 
| $$ | 
| DELIMITER ; | 
| CALL p1(10,'B0'); | 
| CALL p1(11,'B1'); | 
| CALL p1(12,'B2'); | 
| CALL p1(12,'non-existing'); | 
| DROP TABLE t1; | 
| DROP PROCEDURE p1; | 
The expected output is:
| +-------+-------+ | 
| | rec.a | rec.b | | 
| +-------+-------+ | 
| |    10 | b0    | | 
| +-------+-------+ | 
| +-------+-------+ | 
| | rec.a | rec.b | | 
| +-------+-------+ | 
| |    11 | b1    | | 
| +-------+-------+ | 
| +-------+-------+ | 
| | rec.a | rec.b | | 
| +-------+-------+ | 
| |    12 | b2    | | 
| +-------+-------+
 | 
Attachments
Issue Links
- causes
- 
                    MDEV-32275 getting error 'Illegal parameter data types row and bigint for operation '+' ' when using ITERATE in a FOR..DO -         
- Closed
 
-         
- is blocked by
- 
                     MDEV-12098
        sql_mode=ORACLE: Implicit cursor FOR loop MDEV-12098
        sql_mode=ORACLE: Implicit cursor FOR loop-         
- Closed
 
-         
- relates to
- 
                    MDEV-16674 Document FOR loop -         
- Open
 
-