简体   繁体   中英

Insert rows which are missing from tableB from tableA in oracle PL\SQL

I wanted to insert rows into tableB which are missing in table A when i have written the below code on oracle it throws an error "ORA-00913: too many values 00913. 00000 - "too many values"

Please suggest me the correct syntax:

insert into tableB 
Select * from 
(Select * 
from tableA A
left join tableB B
on a.id = B.id
and a.year = b.year
where (a.id is null or a.year is null) )A;

ISNULL condition need to be on the tableB's column and you need to select only tableA column values.

insert into tableB 
Select * from 
(Select A.* 
from tableA A
left join tableB B
on a.id = B.id
and a.year = b.year
where (b.id is null or b.year is null) )A;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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