Skip to content

[Feature] Prostgres Procedural DO $$BEGIN ... END$$ #1946

Description

@zdhuangelephant

Always check against the Latest SNAPSHOT of JSQLParser and the Syntax Diagram

Failing SQL Feature:

  • Brief description of the failing SQL feature
  • Example: Encountered unexpected token: "DO" "DO" can't be parsed

SQL Example:

  • Simplified Query Example, focusing on the failing feature

DO $$
BEGIN
IF NOT EXISTS( select 1 from comm.permission_operation where permission_operation_code = 'ecg_report_time_modify') and EXISTS( select 1 from comm.permission where permission_code = 'data_modify')
THEN
INSERT INTO comm.permission_operation
(permission_operation_id,
permission_id,
permission_operation_code,
permission_operation_name,
"type",
"version",
his_org_id,
his_creater_id,
his_creater_name,
his_create_time,
his_updater_id,
his_update_time)
VALUES
((select max(permission_operation_id) + 1 from comm.permission_operation),
(select permission_id from comm.permission where permission_code = 'data_modify' limit 1),
'ecg_report_time_modify',
'心电报告时间修改',
'1',
0,
(select his_org_id from comm.hospital limit 1),
1,
'系统管理员',
now(),
1,
now()) on conflict(permission_operation_id) do nothing;
END IF;
END $$;
```

Software Information:

  • JSqlParser 4.7
  • Database PostgreSQL

Exception in thread "main" net.sf.jsqlparser.JSQLParserException: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "DO" "DO" at line 1, column 1.

Activity

  1. zdhuangelephant commented on Jan 15, 2024

    @zdhuangelephant
    Author

    image

  2. manticore-projects commented on Jan 15, 2024

    @manticore-projects
    Contributor

    Greetings!

    PostgreSQL specific DO is not supported and you will need to provide or sponsor an implementation when you are interested in this particular feature.

  3. zdhuangelephant commented on Jan 15, 2024

    @zdhuangelephant
    Author

    image
    is that not working ?

  4. changed the title [-][BUG] JSQLParser Version : RDBMS : failing feature description[/-] [+][Feature] Prostgres Procedural `DO $$BEGIN ... END$$`[/+] on Jan 15, 2024
  5. manticore-projects commented on Jan 15, 2024

    @manticore-projects
    Contributor

    is that not working ?

    It is working by only passing through the text block. You would at least introduce a DO $$BEGIN ... END$$ statement and certainly you will want to parse this block in order to get the AST of your INSERT ... statement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions