我正在尝试做一个本质上非常简单的任务,结果是:
ORA-00928: missing SELECT keyword
我要做的就是将 periods
的结果保存到表 globalTable
中。选择工作正常(我返回行)但是一旦我用 Insert 替换它我就会收到上述错误。
create global temporary table globalTable
(
ids number(11)
);
with periods as
(
select cl.id uniqueId
from inv_mpan_hh_con_lines cl
left join invoice_vat_lines vl on
cl.invoice_id = VL.INVOICE_ID
where rownum < 4
)
--//Issue occurs at insert keyword. If I comment it and uncomment select it works as expected//--
--select uniqueId
insert into globalTable
from periods;
非常感谢任何指点。
最佳答案
试试这个:
insert into globalTable
with periods as
(
select cl.id uniqueId
from inv_mpan_hh_con_lines cl
left join invoice_vat_lines vl
on cl.invoice_id = VL.INVOICE_ID
where rownum < 4
)
select uniqueId
from periods;
CTE
(WITH-clause) 是 SELECT
语句的一部分,根据 INSERT
语法,您可以指定值或 SELECT
语句
关于sql - Insert Into 使用 WITH 子句 (CTE) 导致 ORA-00928,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25323833/