TABLE_A:
ID TYPE DATE_UPLOADED EXPIRED
9872 APPLE 03-JAN-11 0
9874 MANGO 03-JAN-11 0
9873 GRAPE 03-JAN-11 0
TABLE_B:
TYPE LIFE
APPLE 3
MANGO 2
GRAPE 1
What I would like to achieve here is to update the EXPIRED
field of TABLE_A
to a value of 1
when it's DATE_UPLOADED
has exceeded it's LIFE
for that type as of the current date.
This update query is where I'm currently stuck with. I know its
wrong, that's where I need your help.
Update query:
UPDATE TABLE_A
SET EXPIRED = 1
WHERE EXPIRED = 0
AND (TRUNC(SYSDATE) - TRUNC(DATE_UPLOADED)) >
(
SELECT LIFE
FROM TABLE_B
);
Do note that the TYPE
field may be anything and may be more
than what is given in the sample data.