繁体   English   中英

在Oracle中插入行时出错

[英]Error inserting rows in oracle

我在插入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;

错误:

   SQL Error: ORA-00947: not enough values
   00947. 00000 -  "not enough values"

直接的错误是您在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列。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM