Skip to Main Content

Oracle Database Free

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Cannot project boolean expressions in JSON functions

Lukas EderApr 5 2023

I'm using: https://hub.docker.com/r/gvenzl/oracle-free

The BOOLEAN type is now widely supported (yay!), e.g. this works:

select 1 = 1

I can also use BOOLEAN literals in JSON functions:

select json_array(true);

This produces:

|JSON_ARRAY(TRUE)|
|----------------|
|[true]          |

But I can't use a BOOLEAN expression in JSON, it seems:

select json_array(1 = 1);

This raises an error:

SQL Error [2000] [42000]: ORA-02000: missing ) keyword

Workaround, use a subquery:

select json_array(select 1 = 1);

Same problem with this convenience syntax:

select json [ 1 = 1 ]

The error is:

SQL Error [2000] [42000]: ORA-02000: missing ] keyword

Same workaround:

select json [ select 1 = 1 from dual ]

Notice, FROM dual is needed because of https://forums.oracle.com/ords/apexds/post/json-convenience-syntax-requires-from-clause-in-subquery-6359

JSON_OBJECT is also affected. This doesn't work:

select json_object(key 'a' value 1 = 1)

This works:

select json_object(key 'a' value (select 1 = 1))
This post has been answered by Loïc Lefèvre-Oracle on Apr 5 2023
Jump to Answer
Comments
Post Details
Added on Apr 5 2023
2 comments
393 views