以前怕重复是 DELETE FROM table WHERE ETL_DATE = TO_DATE(P_END_DATE_TO, 'YYYY-MM-DD'); COMMIT;这样是按日期删除数据 但后来发现有些数据会回写 这样只能按主键来删除 怎么写这个语句呢?
create or replace pro_test as v_temp number(10); begin select count(*) into v_temp from table_name where ..... if v_temp > 0 THEN delete from table_name; end if insert into table_name..... end;
DELETE FROM table WHERE ETL_DATE = TO_DATE(P_END_DATE_TO, 'YYYY-MM-DD');
COMMIT;这样是按日期删除数据 但后来发现有些数据会回写 这样只能按主键来删除 怎么写这个语句呢?
as
v_temp number(10);
begin
select count(*) into v_temp from table_name where .....
if v_temp > 0 THEN
delete from table_name;
end if
insert into table_name.....
end;