Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-34317

DECLARE TYPE type_name IS RECORD (..) with scalar members in stored routines

    XMLWordPrintable

Details

    Description

      Let's add support for TYPE type_name IS RECORD (..) inside the DECLARE section stored routines and anonymous blocks, with these limitations:

      • The record members can be of scalar data types only
      • The NOT NULL clause inside members won't be supported
      • The default values for members won't be supported

      Example:

      DECLARE
        TYPE DeptRecTyp IS RECORD (
          dept_id    NUMBER(4),
          dept_name  VARCHAR2(30),
          mgr_id     NUMBER(6),
          loc_id     NUMBER(4)
        );
        dept_rec DeptRecTyp:= DeptRecTyp(11,'a',201,1700);
        str VARCHAR(1024);
      BEGIN
        str:= 
         'dept_id:   ' || dept_rec.dept_id   || '; ' ||
         'dept_name: ' || dept_rec.dept_name || '; ' ||
         'mgr_id:    ' || dept_rec.mgr_id    || '; ' ||
         'loc_id:    ' || dept_rec.loc_id;
        DBMS_OUTPUT.PUT_LINE(str);
      END;
      

      dept_id: 11; dept_name: a; mgr_id: 201; loc_id: 1700
      

      Record members should support the anchored %TYPE attribute:

      CREATE TABLE t1
      (
          dept_id    NUMBER(4),
          dept_name  VARCHAR2(30),
          mgr_id     NUMBER(6),
          loc_id     NUMBER(4)
      );
       
      DECLARE
        TYPE DeptRecTyp IS RECORD (
          dept_id    t1.dept_id%TYPE,
          dept_name  t1.dept_name%TYPE,
          mgr_id     t1.mgr_id%TYPE,
          loc_id     t1.loc_id%TYPE
        );
        dept_rec DeptRecTyp:= DeptRecTyp(11,'a',201,1700);
        str VARCHAR(1024);
      BEGIN
        str:= 
         'dept_id:   ' || dept_rec.dept_id   || '; ' ||
         'dept_name: ' || dept_rec.dept_name || '; ' ||
         'mgr_id:    ' || dept_rec.mgr_id    || '; ' ||
         'loc_id:    ' || dept_rec.loc_id;
        DBMS_OUTPUT.PUT_LINE(str);
      END;
      

      Attachments

        Issue Links

          Activity

            People

              ramesh Ramesh Sivaraman
              bar Alexander Barkov
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.