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

Parse error when using set operation with path keyword in json_transform #45

Open
PhilippSalvisberg opened this issue Jul 3, 2024 · 0 comments
Assignees
Labels
23.4 bug Something isn't working

Comments

@PhilippSalvisberg
Copy link
Collaborator

The following statement causes parser errors:

update dept_dv v
   set v.data = json_transform(
                   v.data, 
                   set '$.street' = '85 Albert Embankment',
                   nested '$.emps[*]' (
                      set '@.sal' = path '@.sal * 42'
                   ),
                   nested '$.emps[*]?(@.ename == "BOND")' (
                      set '@.sal' = path '@.sal + 1',
                      append '@.tools' = 'Aston Martin DB5'
                   )
                )
 where v.data."_id".numberOnly() = 50;

The set operation was not fully documented in SQL Language Reference for 23c as of December 2023. The path keyword was missing.

The following statement works without the path keyword (and therefore using a literal instead of a JSON path):

update dept_dv v
   set v.data = json_transform(
                   v.data, 
                   set '$.street' = '85 Albert Embankment',
                   nested '$.emps[*]' (
                      set '@.sal' =  10
                   ),
                   nested '$.emps[*]?(@.ename == "BOND")' (
                      set '@.sal' =  20,
                      append '@.tools' = 'Aston Martin DB5'
                   )
                )
 where v.data."_id".numberOnly() = 50;

Documentation was fixed in May 2024. See https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_TRANSFORM.html#GUID-DD2A821B-C688-4310-81B5-5F45090B9366__GUID-1BBA7230-9695-482E-B686-BADB0724F307 . Therefore I assign the label 23.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
23.4 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants