JSON_TRANSFORM

Syntax

Description of the illustration json_transform.gif

(operation::=, JSON_TRANSFORM_returning_clause::=, JSON_passing_clause::= )

JSON_TRANSFORM_returning_clause::=

Description of the illustration json_transform_returning_clause.gif

JSON_passing_clause::=

For details on JSON_passing_clause see JSON_EXISTS Condition.

operation::=

Description of the illustration operation.gif

(add_set_op::=,append_op::=, case_op::=,copy_op::=,insert_op::=,intersect_op::=,keep_op::=,merge_op::=,minus_op::=,nested_path_op::=,prepend_op::=,remove_op::=,rename_op::=,remove_set_op::=,replace_op::=,set_op,sort_op,union_op,)

add_set_op::=

Description of the illustration add_set_op.gif

append_op::=

Description of the illustration append_op.gif

rhs_expr::=

case_op::=

Description of the illustration case_op.gif

copy_op::=

Description of the illustration copy_op.gif

rhs_expr::=

insert_op::=

Description of the illustration insert_op.gif

rhs_expr::=

intersect_op::=

Description of the illustration intersect_op.gif

rhs_expr::=

keep_op::=

Description of the illustration keep_op.gif

merge_op::=

Description of the illustration merge_op.gif

rhs_expr::=

minus_op::=

Description of the illustration minus_op.gif

rhs_expr::=

nested_path_op::=

Description of the illustration nested_path_op.gif

prepend_op::=

Description of the illustration prepend_op.gif

rhs_expr::=

remove_op::=

Description of the illustration remove_op.gif

remove_set_op::=

Description of the illustration remove_set_op.gif

rename_op::=

Description of the illustration rename_op.gif

replace_op::=

Description of the illustration replace_op.gif

rhs_expr::=

set_op::=

Description of the illustration set_op.gif

rhs_expr::=

sort_op::=

Description of the illustration sort_op.gif

union_op::=

Description of the illustration union_op.gif

rhs_expr::=

rhs_expr::=

Description of the illustration rhs_expr.gif

Purpose

JSON_TRANSFORM modifies JSON documents. You specify operations to perform and SQL/JSON path expressions that target the places to modify. The operations are applied to the input data in the order specified: each operation acts on the data that results from applying all of the preceding operations.

JSON_TRANSFORM either succeeds completely or not at all. If any of the specified operations raises an error, then none of the operations take effect. JSON_TRANSFORM returns the original data changed according to the operations specified.

You can use the JSON_TRANSFORM within the UPDATE statement to modify documents in a JSON column.

You can use it in a SELECT list, to modify the selected documents. The modified documents can be returned or processed further.

JSON_TRANSFORM can accept as input, and return as output, any SQL data type that supports JSON data: JSON, VARCHAR2, CLOB, or BLOB. Note that data type JSON is available only if database initialization parameter compatible is 20 or greater.

The default return (output) data type is the same as the input data type.

See Also: * Oracle SQL Function JSON_TRANSFORM of the JSON Developer’s Guide* for a full discussion with examples.

JSON_TRANSFORM Operations

TYPE Clause

For a full discussion of STRICT and LAX syntax see About Strict and Lax JSON Syntax, and TYPE Clause for SQL Functions and Conditions

JSON_passing_clause

You can use JSON_passing_clause to specify SQL bindings of bind variables to SQL/JSON variables similar to the JSON_EXISTS condition and the SQL/JSON query functions.

JSON_TRANSFORM_returning_clause

After you specify the operations you can use JSON_TRANSFORM_returning_clause to specify the return data type.

Examples

Example 1 : Update a JSON Column with a Timestamp

UPDATE t SET jcol = JSON_TRANSFORM(jcol, SET '$.lastUpdated' = SYSTIMESTAMP)

Example 2 : Remove a Social Security Number before Shipping JSON to a Client

SELECT JSON_TRANSFORM (jcol, REMOVE '$.ssn') FROM t WHERE ...

JSON_TRANSFORM_returning_clause

If the input data is JSON, then the output data type is also JSON. For all other input types, the default output data type is VARCHAR2(4000).