Re: Catching date conversion exceptions in PL/SQL ...

From: DA Morgan <damorgan_at_exesolutions.com>
Date: Mon, 16 Dec 2002 10:28:20 -0800
Message-ID: <3DFE1B44.6521BFE3_at_exesolutions.com>


Ludwig Nörg wrote:

> Hello guys,
>
> I try to convert a number field in the format '[d]dmmyy' with the
> following construct:
>
> FUNCTION conv_birthday(birthday NUMBER) RETURN DATE IS
> ret_birthday DATE;
> BEGIN
> ret_birthday := TO_DATE(LPAD(TO_CHAR(birthday),6,'0'),
> 'ddmmyy');
> EXCEPTION
> WHEN OTHERS THEN
> ret_birthday := NULL;
>
> RETURN ret_birthday;
> END conv_birthday;
>
> In case the conversion fails I would like to receive a NULL value, but
> it does not work. It returns with error code ORA-06503 and ORA-06512.
> Can anybody fix this piece of code?
>
> Thanx in advance,
> Ludwig Nörg

And you are going to ask us look up the error message it fails with?

Dan Morgan Received on Mon Dec 16 2002 - 19:28:20 CET

Original text of this message