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

DECLARE TYPE .. TABLE OF .. INDEX BY in stored routines

    XMLWordPrintable

Details

    Description

      Let's add support for INDEX BY tables (associative arrays) in the DECLARE section of stored routines and anonymous blocks, with this syntax:

      DECLARE
        TYPE type_name TABLE OF rec_type_name INDEX BY idx_type_name;
      

      The INDEX BY clause should support at least integer and string data types.

      rec_type_name should support scalar both types and records:

      DECLARE
        TYPE salary IS TABLE OF NUMBER INDEX BY VARCHAR2(20);
        salary_list salary;
        name VARCHAR2(20);
      BEGIN
        salary_list('Rajnisj') := 62000;
        salary_list('James') := 78000;
        name:= salary_list.FIRST;
        WHILE name IS NOT NULL
        LOOP
          dbms_output.put_line(name || ' ' || TO_CHAR(salary_list(name)));
          name:= salary_list.NEXT(name);
        END LOOP;
      END;
      /
      

      DECLARE
        TYPE person_t IS RECORD
        (
          first_name VARCHAR(64),
          last_name VARCHAR(64)
        );
        TYPE table_of_peson_t IS TABLE OF person_t INDEX BY VARCHAR(20);
        person_by_nickname table_of_peson_t;
        nick VARCHAR(20);
      BEGIN
        person_by_nickname('Monty') := person_t('Michael', 'Widenius');
        person_by_nickname('Serg') := person_t('Sergei ', 'Golubchik');
        nick:= person_by_nickname.FIRST;
        WHILE nick IS NOT NULL
        LOOP
          dbms_output.put_line(nick || ' ' || TO_CHAR(person_by_nickname(nick)));
          name:= person_by_nickname.NEXT(nick);
        END LOOP;
      END;
      /
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              bar Alexander Barkov
              Votes:
              1 Vote for this issue
              Watchers:
              4 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.