Experts Exchange connects you with the people and services you need so you can get back to work.
CREATE PROC p_some_proc() AS
INSERT INTO TargetTable (id, goo, foo, boo)
SELECT id, goo, foo, boo
FROM SourceTable s
-- LEFT means all rows from source table will be added...
LEFT JOIN TargetTable t ON s.id = t.id
-- WHERE the target.pk is null means only source rows that aren't already in target
WHERE t.id IS NULL
Open in new window
At Springboard, we know how to get you a job in data science. With Springboard’s Data Science Career Track, you’ll master data science with a curriculum built by industry experts. You’ll work on real projects, and get 1-on-1 mentorship from a data scientist.
drop table tab1 purge;
drop table tab2 purge;
create table tab1( col1 char(1), col2 char(1));
create table tab2( col1 char(1), col2 char(1));
insert into tab1 values('a','1');
insert into tab1 values('b','2');
insert into tab2 values('a','1');
create or replace procedure myproc
merge into tab2 t2 using
(select col1, col2 from tab1) t1
on (t1.col1=t2.col1 and t1.col2=t2.col2)
when not matched then insert(t2.col1,t2.col2) values(t1.col1,t1.col2);
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
It’s our mission to create a product that solves the huge challenges you face at work every day. In case you missed it, here are 7 delightful things we've added recently to monday to make it even more awesome.