PL/SQL parser - Phase 2 (MDEV-10764)

[MDEV-11781] sql_mode=ORACLE: IN, OUT, IN OUT modes for dynamic SQL bind arguments Created: 2017-01-12  Updated: 2023-10-20

Status: Open
Project: MariaDB Server
Component/s: Parser
Affects Version/s: None
Fix Version/s: None

Type: Technical task Priority: Major
Reporter: Alexander Barkov Assignee: Unassigned
Resolution: Unresolved Votes: 3
Labels: Compatibility

Issue Links:
Relates
relates to MDEV-10585 EXECUTE IMMEDIATE statement Closed
relates to MDEV-10709 Expressions as parameters to Dynamic SQL Closed

 Description   

We'll support IN, OUT and IN OUT modes for bind arguments when running in sql_mode=ORACLE, according to the following grammar:

execute_immediate_statement ::=
EXECUTE_IMMEDIATE dynamic_string
   [ INTO { define_variable [, define_variable ...] | record_name } ]
   [ USING [ IN | OUT | IN OUT ] bind_argument
       [, [ IN | OUT | IN OUT ] bind_argument] ... ]
   [ {RETURNING | RETURN } INTO bind_argument [, bind_argument]... ];

Example:

DECLARE
  plsql_block VARCHAR2(500);
  new_deptid  NUMBER(4);
  new_dname   VARCHAR2(30) := 'Advertising';
  new_mgrid   NUMBER(6)    := 200;
  new_locid   NUMBER(4)    := 1700;
BEGIN
 -- Dynamic PL/SQL block invokes subprogram:
  plsql_block := 'BEGIN create_dept(:a, :b, :c, :d); END;';
 
 /* Specify bind arguments in USING clause.
    Specify mode for first parameter.
    Modes of other parameters are correct by default. */
  EXECUTE IMMEDIATE plsql_block
    USING IN OUT new_deptid, new_dname, new_mgrid, new_locid;
END;
/


Generated at Thu Feb 08 07:52:36 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.