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

Call procedures dynamically with table/field names

    XMLWordPrintable

Details

    • Task
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • None
    • Stored routines
    • None

    Description

      Hi everyone. Allow the procedures and / or functions of MariaDB to receive parameters like table name, view name, temporary table name, and / or field names, and that can be processed dynamically, for ACID operations and for declaration of cursors. For example:

      CREATE PROCEDURE procedure1
      (
      p_tableName varchar(99),
      p_fieldName varchar(99)
      )
      BEGIN
      UPDATE @p_tableName SET @p_fieldName = @p_fieldName * 10;
      INSERT INTO @p_tableName (@p_fieldName) VALUES (0);
      DELETE FROM @p_tableName where (@p_fieldName)<1;
      DECLARE myCursor CURSOR FOR SELECT @p_fieldName FROM @p_tableName;
      END;

      CALL procedure1('customers','bonus');
      CALL procedure1('customers2','extra');

      Thank yo so much.

      Attachments

        Activity

          People

            Unassigned Unassigned
            ceau74 ceau
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.