[Feature] Prostgres Procedural `DO $$BEGIN ... END$$`
zdhuangelephant opened this issue · comments
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.
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.
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.