Skip to Main Content

ORDS, SODA & JSON in the Database

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!

Date conversion from JSON into mview

dba94403May 11 2022

I am running 21c on-prem with a JSON table with JSON data type. In the JSON document there is a dateofbirth field in a 14 digits number format (YYYYMMDDHH24MISS). I like to create a fast refresh materialized view and convert the number to a date without time on the fly. Is there a way to handle the conversion in the create mview statement? Below is my original script without date conversion. Thanks.

CREATE MATERIALIZED VIEW mv_test
BUILD IMMEDIATE REFRESH FAST ON COMMIT WITH PRIMARY KEY
AS SELECT t.id, jt.*
FROM test t,
json_table(t.json_document, '$' ERROR ON ERROR NULL ON EMPTY
COLUMNS (
order_id NUMBER PATH '$.orderid',
date_of_birth NUMBER PATH '$.dateofbirth'
)) jt;

This post has been answered by Solomon Yakobson on May 12 2022
Jump to Answer
Comments
Post Details
Added on May 11 2022
2 comments
297 views