[英]Oracle 12C - %TYPE in JSON_TABLE column doesn't work
I'm trying to save a JSON array as database rows:我正在尝试将 JSON 数组保存为数据库行:
INSERT INTO ca_kiosk_browser_log (
"uuid",
"date",
"msg",
"level"
)
WITH t ( log ) AS (
SELECT
JSON_QUERY('[{"uuid": "20000000-0000-0000-0000-000000000000", "date": "2021-10-17", "msg":"aaaa", "level": "debug" },
{"uuid": "20000000-0000-0000-0000-000000000000", "date": "2021-10-17", "msg":"bbbb", "level": "debug" }]'
, '$')
FROM
dual
)
SELECT
"uuid",
"date",
"msg",
"level"
FROM
t
CROSS JOIN
JSON_TABLE ( log, '$'
COLUMNS (
NESTED PATH '$[*]'
COLUMNS (
"uuid" VARCHAR2 ( 36 ) PATH '$.uuid',
"date" DATE PATH '$.date',
"msg" VARCHAR2 ( 1024 ) PATH '$.msg',
"level" VARCHAR2 ( 5 ) PATH '$.level'
)
)
)
When I try to use the %type
:当我尝试使用
%type
:
NESTED PATH '$[*]'
COLUMNS (
"uuid" VARCHAR2 ( 36 ) PATH '$.uuid',
"date" my_table.date%type PATH '$.date',
"msg" VARCHAR2 ( 1024 ) PATH '$.msg',
"level" VARCHAR2 ( 5 ) PATH '$.level'
)
I get an error:我收到一个错误:
SQL Error: ORA-40484: invalid data type for JSON_TABLE column
40484. 00000 - "invalid data type for JSON_TABLE column"
*Cause: A column in the provided JSON_TABLE had an unsupported data type.
*Action: Provide a supported data type.
Even though the type in the column is also date
.即使列中的类型也是
date
。
Also the type char(36)
doesn't work, so I have to use VARCHAR2(36)
.类型
char(36)
也不起作用,所以我必须使用VARCHAR2(36)
。
Is it possible to use %type
in this case?在这种情况下可以使用
%type
吗?
The JSON_TABLE
documentation gives the syntax for the JSON query column clause: JSON_TABLE
文档提供了 JSON 查询列子句的语法:
Following the link to the JSON_value_return_type
documentation tells you the allowable data types:按照
JSON_value_return_type
文档的链接告诉您允许的数据类型:
Given this, no, you cannot use %TYPE
or CHAR
as the JSON_TABLE
syntax does not allow it.鉴于此,不,您不能使用
%TYPE
或CHAR
因为JSON_TABLE
语法不允许它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.