我试图做一个本质上非常简单的任务,结果是:
ORA-00928:缺少SELECT关键字
我尝试做的只是将periods
的结果保留在表globalTable
中。选择工作正常(我返回了行)但是只要我用插入替换它就会出现上述错误。
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;
非常感谢任何指针。
答案 0 :(得分:4)
试试这个:
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
语句