I've came across the following SQL/PLSQL while investigating a stored procedure written by someone else:
1. V_COUNT NUMBER(5,0); ......... 2. SELECT COUNT(*) INTO V_COUNT FROM TABLE1 WHERE COL1='SOMEVALUE'; 3. IF V_COUNT>0 THEN 4. DELETE FROM TABLE1 WHERE COL1='SOMEVALUE'; 5. END IF;
Isn't only the DELETE statement in the line 4 sufficient to cover all the logic that's meant with these 5 lines? I first thought maybe V_COUNT is used somewhere else, but it's not. I can't think of any good reason in making a simple delete statement so complex. Do you also think it's a bad design or is there a point that I can't see?