Hi All,
Good morning!
Recently i have come across the below error and i need your help on understanding where i am missing:
Error report:
ORA-01867: the interval is invalid
ORA-06512: at line 6
01867. 00000 - "the interval is invalid"
*Cause: The character string you specified is not a valid interval.
*Action: Please specify a valid interval.
Description:
=========
When I use the below piece of code i got the above specified error.
DECLARE
v_dt_iy2m INTERVAL YEAR TO MONTH;
x_dob DATE := '07-JUN-1987';
x_today DATE := '26-DEC-2013';
BEGIN
v_dt_iy2m :=
TO_CHAR (EXTRACT (YEAR FROM x_today) - EXTRACT (YEAR FROM x_dob))
|| '+'
|| TO_CHAR (EXTRACT (MONTH FROM x_today)
- EXTRACT (MONTH FROM x_dob));
DBMS_OUTPUT.put_line (v_dt_iy2m);
END;
here i have noted down that when i use '+' operator in the CONCATENATION function system throws the error, Whereas if i use '-' (minus) symbol, the above code just works fine.
Can someone please assist me what am i am missing/misunderstanding here?
Thanks,
Thiru.