我正在尝试使用 Oracle SQL 将附加行添加到 CTE 表,但无法完全正常工作。我已经阅读过,似乎使用 INSERT INTO () 是我的最佳选择,但我觉得我错过了一些简单的东西,并且在“插入”时出现语法错误。
下面是我试图插入的代码,我在这一点之上有几个 CTE(即,WITH table as ()、table2 as ()、table3 as () 等),但下面是我得到的部分我的错误:
region as (
select City, County
from clarity_pos cp
left join zc_county zc on zc.county_c = cp.county_c
where cp.county_c is not null
)
Insert into
region (City, County)
Values
('AMSTON', 'TOLLAND')
,('BURLINGTON', 'HARTFORD')
,('COVENTRY', 'TOLLAND')
,('DARIAN', 'FAIRFIELD')
,('EAST LYME', 'NEW LONDON')
Select City, County
from region
保留
REGION
CTE 的代码原样,然后通过联合添加其他行,例如
WITH
region AS
(
-- original code
SELECT city,
county
FROM clarity_pos cp
left join zc_county zc
ON zc.county_c = cp.county_c
WHERE cp.county_c IS NOT NULL
-- now add additional rows:
UNION ALL
SELECT 'AMSTON',
'TOLLAND'
FROM dual
UNION ALL
SELECT 'BURLINGTON',
'HARTFORD'
FROM dual )
SELECT city,
county
FROM region