18.7 TYPE Clause for SQL Functions and Conditions
Oracle SQL function json_transform, SQL/JSON
functions json_query, json_value and
json_table, and SQL/JSON condition json_exists accept
optional TYPE clauses, which specify whether JSON values are
compared strictly with respect to JSON-language type, that is, as if the relevant
"only" data-type conversion item methods were applied to the data being
compared.
Keyword TYPE is followed, in parentheses, by keyword
STRICT or LAX.
-
TYPE (LAX)specifies the default behavior (same as noTYPEclause), which is that JSON values can be implicitly interpreted (essentially cast) as values of SQL data types for purposes of comparison. This type-casting is explained in Types in Filter-Condition Comparisons.For example, a comparison such as
'$.PONumber?(@ > 20)implicitly interprets aPONumbervalue of"314"as the number314(because it is compared with the number 20). That comparison is true, just as if the expression were'$.PONumber?(@.number() > 20) -
TYPE (STRICT)has the same effect as applying "only" item methods.For example,
'$.PONumber?(@ > 20)behaves as if it were'$.PONumber?(@.numberOnly() > 20). For aPONumbervalue of"314"the comparison is false, just as if the expression were'$.PONumber?(@.numberOnly() > 20).
See Also:
JSON_QUERY in Oracle Database SQL Language Reference
Parent topic: Clauses Used in SQL Functions and Conditions for JSON