efficient update program
I have a table emp with columns (hiredate date, birthdate date);
I want to update the two columns set to NULL if their value is
greater than sysdate. Like this:
sql> update emp set hiredate=null where hiredate>sysdate;
sql> update emp set birthdate=null where birthdate>sysdate;
How can i write this on one command line (maybe using decode)
so i wont re-read the table again, thus making it efficient.
I want one pass to the table.
Thanks a lot
set hiredate =
case when hiredate > sysdate then
else hiredate end,
case when birthdate > sysdate then
else birthdate end
birthdate > sysdate or hiredate > sysdate
"I Dont Want To Follow A Path, I would Rather Go Where There Is No Path And Leave A Trail."
"Ego is the worst thing many have, try to overcome it & you will be the best, if not good, person on this earth"
Thanks hun, hmmnnn new look in sqlplus command. it looks like
pl/sql...i learned a new technique again, if u want to evaluate/validate all columns you can use CASE.
Click Here to Expand Forum to Full Width