我在插入oracle时遇到了麻烦。我不知道查询有什么问题。请帮我解决这个错误。谢谢..
查询:
insert into import_temp(reference,col1,col2,col3,col4,col5,col6,col7,col8,col9,col10,col11,col12,col13)
select a.reference,a.field_name
,max(a.user_name) as username, max(a.timestamp) as timestamp
from (
select distinct 'VAL-'||t.reference as reference
,case -- tracker information validation
when (row_number() over (order by id))=1 and trim(replace(col1,chr(13),''))='Tracker.Antifraud.Input' then 'tracker'
-- header validation
when (row_number() over (order by id))<3 then 'header1'
when (row_number() over (order by id))=3 and trim(col1)<>'Column1' then 'Unknown column '||t.col1
when (row_number() over (order by id))=3 and trim(col2)<>'Column2' then 'Unknown column '||t.col2
when (row_number() over (order by id))=3 and trim(col3)<>'Column3' then 'Unknown column '||t.col3
when (row_number() over (order by id))=3 and trim(col4)<>'Column4' then 'Unknown column '||t.col4
when (row_number() over (order by id))=3 and trim(col5)<>'Column5' then 'Unknown column '||t.col5
when (row_number() over (order by id))=3 and trim(col6)<>'Column6' then 'Unknown column '||t.col6
when (row_number() over (order by id))=3 and trim(col7)<>'Column7' then 'Unknown column '||t.col7
when (row_number() over (order by id))=3 and trim(col8)<>'Column8' then 'Unknown column '||t.col8
when (row_number() over (order by id))=3 and trim(col9)<>'Column9' then 'Unknown column '||t.col9
when (row_number() over (order by id))=3 and trim(col10)<>'Column10' then 'Unknown column '||t.col10
when (row_number() over (order by id))=3 and trim(col11)<>'Column11' then 'Unknown column '||t.col11
when (row_number() over (order by id))=3 and trim(col12)<>'Column12' then 'Unknown column '||t.col12
when (row_number() over (order by id))=3 and trim(col13)<>'Column13' then 'Unknown column '||t.col13
when (row_number() over (order by id))=3 then 'header'
-- record validation
when (row_number() over (order by id))>3 then 'record'
else 'unknown row '||(row_number() over (order by id))
end as field_name
,case when (row_number() over (order by id))=1 then trim(t.col5) end as user_name
,case when (row_number() over (order by id))=1 and isdate(trim(t.col10),'yyMMddhh24miss')='Y' then trim(t.col10) end as timestamp
from params p
inner join import_temp t on p.GUID=t.reference
where not t.col1 is null
) a
group by a.reference,a.field_name;
ERROR:
SQL Error: ORA-00947: not enough values
00947. 00000 - "not enough values"
答案 0 :(得分:1)
立即错误是您在INSERT
子句中列出了14列,但您的SELECT
只返回4列。
insert into import_temp(reference,col1,col2,col3,col4,col5,col6,col7,
col8,col9,col10,col11,col12,col13)
-- 14 columns above
--
-- 4 columns below
select a.reference,a.field_name
,max(a.user_name) as username, max(a.timestamp) as timestamp
from (
根据列名称,我SELECT
只返回INSERT
中指定的前4列,这对我来说并不明显。