m.e*_*son 3 sql oracle toad oracle10g sql-insert
我正在尝试做一个本质上非常简单的任务,结果是:
ORA-00928:缺少SELECT关键字
我要做的就是将结果持久化periods到table中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;
Run Code Online (Sandbox Code Playgroud)
非常感谢任何指针。
尝试这个:
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;
Run Code Online (Sandbox Code Playgroud)
CTE(带子句)是SELECT语句的一部分,根据INSERT语法,您可以指定值或SELECT语句