Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to delete the records checking data and time

976208Oct 28 2013 — edited Oct 28 2013

Hi Experts,

I want to delete the records which are less than or equal to this date  MIN(TRUNC(sale_week_date)-(1/(24*60*60)))

For that I have created the following procedure.

CREATE OR REPLACE PROCEDURE DELETE_DATA_WEEK

IS

MIN_DATE DATE;

SELECT MIN(TRUNC(sale_week_date)-(1/(24*60*60))) INTO MIN_DATE FROM sales_week;

DBMS_OUTPUT.PUT_LINE(MIN_DATE);

DELETE FROM sales

WHERE sale_date <= MIN_DATE

AND sales_creation_date <= MIN_DATE

AND sales_update_date <= MIN_DATE;

END;

If declare as MIN_DATE Date; it's not taking time.

If declare as MIN_DATE Timestamp; It is taking milli seconds also. 18-OCT-13 11.59.59.000000 PM

SALE_DATE ,SALES_CREATION_DATE and SALES_UPDATE_DATE in this  format  18-OCT-2013 11.59.59 AM.

Please help me.

How  to delete the records which are less than or equal to this date  MIN(TRUNC(sale_week_date)-(1/(24*60*60))) .

Thanks.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 25 2013
Added on Oct 28 2013
9 comments
591 views