I created a stored procedure to calcuate the day you were born. I want it to throw an exception if the date is in the future or if the date is invalid such as a leap like February 30, 1977. i have included this logic but it is not throwing the exceptions. I have used sysdate to calculate aginst any future dayes as you will see below in the code.
Any idea why I can't get the exceptions to work?
I am using Oracle.
exec Day (February 30, 1977);
It looks like the line
should cause the error when executing the to_date part because this function can only take valid looking dates. This means that the logic you have does not actually trap the e_invalid_day but still it should show you some error. I mean that if invalid date is passed then to_date fails and the code never gets to the line reading CASE v_dnum so the logic to trap invalid date input should be somewhat different, but I cannot see why the flow does not branch to the catch all WHEN OTHERS part.
answered Oct 10 '11 at 04:40 PM