Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mysql: create procedure LOOP bug #729

Open
zundaren opened this issue Mar 23, 2024 · 1 comment
Open

mysql: create procedure LOOP bug #729

zundaren opened this issue Mar 23, 2024 · 1 comment
Labels

Comments

@zundaren
Copy link

 label:
 LOOP
        FETCH cur_1 INTO
            event_id,only_code,garage,space;

        IF done THEN
            LEAVE label;
        END IF;

        set @SqlStmtA1 = concat('delete from ', eventtablename, ' where id=', event_id);
        prepare stmtA1 FROM @SqlStmtA1;
        EXECUTE stmtA1;

        COMMIT;
    END LOOP;
    CLOSE cur_1;

image

@zundaren zundaren added the bug label Mar 23, 2024
@nene
Copy link
Collaborator

nene commented Mar 24, 2024

Thanks for reporting.

Unfortunately the support for procedural SQL is pretty much non-existant in SQL-Formatter. Even if it would parse this code without errors, the formatted output would be pretty ugly. Specifically it would be as follows:

label: LOOP FETCH cur_1 INTO event_id,
only_code,
garage,
space;

IF done THEN
LEAVE label;

END IF;

set
  @SqlStmtA1 = concat(
    'delete from ',
    eventtablename,
    ' where id=',
    event_id
  );

prepare stmtA1
FROM
  @SqlStmtA1;

EXECUTE stmtA1;

COMMIT;

END
LOOP;

CLOSE cur_1;

At least I personally wouldn't use it for that.

But yeah, it would be better to not crash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants