Skip to Main Content

Oracle Database Discussions

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!

Oracle 21c: Bug in "json_object()" when using both "json_arrayagg()" and a nested "(select json_object())". ORA-00937

user-99gkcJun 21 2023

I stumbled across this earlier today, as it's impacting my work. I believe it's a bug in Oracle.

The gist of it is that the following query will execute when either of the 2 key/value pairs are present, but never both:

select json_object( 
	key 'foo' 
	value json_arrayagg((select * from dual)), 

	key 'nested' 
	value (select json_object(key 'bar' value 2) from dual) 
) 
from dual;

Try to comment out either foo or nested and see that running either alone will work, but as written above running it gives:

[42000][937] ORA-00937: not a single-group group function Position: 133

Note that unwrapping the nested json_object() from the subquery select also makes it work, which is strange since they should be semantically equivalent:

value json_object(key ‘bar’ value 2)

Is there any way to work around this?

Comments
Post Details
Added on Jun 21 2023
13 comments
1,599 views