Domanda

Sto vivendo un problema sull'inserimento in Oracle.Non so cosa c'è che non va nella query.Per favore aiutami a risolvere quell'errore.Grazie ..

Query:

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;
.

Errore:

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

È stato utile?

Soluzione

L'errore immediato è che elenchi 14 colonne nella clausola INSERT ma il SELECT restituisce solo 4 colonne.

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 (
.

Sulla base dei nomi dei colori, non è ovvio che il tuo SELECT restituisca le prime 4 colonne specificate nel INSERT.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top