I have below query which i am using oracle stored procedure. The query is running fine but i want to add condition in this query such that if the combination of row values with name,e_id,c_date,p_check already exist then do not insert this values.
INSERT INTO M_LOG(NAME, E_ID, C_DATE, STATUS, P_CHECK)
Select MAX(ML.NAME), ML.E_ID, C_DATE, 1, 'M Step_1' from F_LOG ML,DIR_LOG MD
WHERE ML.NAME != MD.NAME and ML.E_ID != MD.E_ID and MD.C_DATE = LAST_DAY(to_date(sysdate,'YYYYMMDD'))
GROUP BY ML.E_ID,C_DATE;
mergeis more flexible, but you might also consider adding anot exists (select ...)to your existinginsert.