Where not exists [message #18531] |
Mon, 04 February 2002 12:54  |
Rm69
Messages: 39 Registered: January 2002
|
Member |
|
|
l've got a procedure that runs to populate table a.Within the same procedure l'm inserting the same data into a history table b. The first run will be okay but if l want to make sure that the records that l insert into table b are not duplicates how will l do that?
Create or replace proc .....
as
begin
end;
insert into...
select ....
from table a;
end;
|
|
|
|
Re: Where not exists [message #18574 is a reply to message #18545] |
Tue, 05 February 2002 20:56  |
Rm69
Messages: 39 Registered: January 2002
|
Member |
|
|
l think l phrased my question wrong. The source is table A. l populate table a using the procedure. Within the same procedure
l then insert the records that l've just inserted in Table A into Table B.This is done on a daily basis and the
only way this data. So my selection should be data thats just been inserted in Table A but does not exist in Table so that l do not insert duplicates in Table B which is just a history table.
My run date is a sysdate which tells me when the run was done and change_date is an actual value passed to a parameter.
My history table should ignore any records from table A so that l have a clean table with no dups
Create or replace proc .....
as
begin
......... just selecting records,summing,count etc...then
end;
INSERT INTO Tab_B_history(
col1 ,
col1,
col1,
Run_date,
change_date)
select
col1 ,
col1,
col1,
Run_date,
change_date
from Tab_A
;
end;
|
|
|