SQL Oracle 中 NUMBER(17,5) 的 CAST 错误

CAST error to NUMBER(17,5) in SQL Oracle

我正在使用 Oracle SQL

有效:

SELECT 
CAST(null as NUMBER(17)) AS COL1
FROM TABLE_A
UNION ALL
SELECT 
TABLE_B.COL1 AS COL1
FROM TABLE_B

但事实并非如此:

SELECT 
CAST(null as NUMBER(17,5)) AS COL1
FROM TABLE_A
UNION ALL
SELECT 
TABLE_B.COL1 AS COL1
FROM TABLE_B

它抛出以下错误:

Error(s) parsing SQL:
Unexpected token near *!* in the following:
CAST(null as NUMBER(17*!*,5)) AS COL1

我不能转换为 NUMBER(17,5) 吗?

注意:COL1 的类型是 NUMBER(17,5)

1) 但是是什么阻止了你这样写:

SELECT 
TABLE_B.COL1 AS COL1
FROM TABLE_B
UNION ALL
SELECT 
CAST(null as NUMBER(17)) AS COL1
FROM TABLE_A

2)

Error(s) parsing SQL: Unexpected token near ! in the following:

不是 Oracle 错误。

3)

SELECT 
CAST(null as NUMBER(17,5)) AS COL1
FROM dual;

在我的环境中工作正常