Re: Help with date conversion - how to handle invalid date
Date: 9 Dec 1998 02:56:59 GMT
Message-ID: <01be231f$6f342800$483c1286_at_itwol-pc3963.itwol.bhp.com.au>
Hi,
[Quoted] Add an exception to pick up the problem, eg.
EXCEPTION
WHEN OTHERS
-- whatever ---
This will pick up any error in the entire procedure, so you could isolate
date problems by writing a function that only does the date conversion, eg.
ELSE
var_check_date := check_date_valid(tr_rec.inventory_end_date);
IF var_check_date IS NULL THEN
-- whatever ---
END;
FUNCTION check_date_valid (tx_date_in IN VARCHAR2)
RETURN DATE IS
dt_return DATE;
BEGIN
dt_return := TO_DATE(tx_date_in, 'YYYYMMDDW');
- in your example, the quotes were missing. -- RETURN dt_return;
EXCEPTION
WHEN OTHERS
null;
-- or message or whatever --
END;
ellen_n_paul_at_my-dejanews.com wrote in article
<74k6ld$imf$1_at_nnrp1.dejanews.com>...
> I'm fairly new at PL/SQL and cannot figure out how to deal with a date
> conversion problem:
>
> I am receiving a date in a 13 char field. I would like to place it into
an
> Oracle date field. Is there anyway for me to check it's validity prior
to
> placing it into the date field and causing an exception if it is not a
valid
> date. If not, is it possible to me to handle the exception within the
current
> block of code?
>
> here is a sample of the problem:
>
> IF tr_rec.inventory_end_date is not null THEN
> err_msg:= 'INVENTORY END DATE '||blank_mand_msg;
> INSERT INTO netout_msgs (net_input_data) VALUES (err_msg);
> rec_err_count := rec_err_count + 1;
> /* ELSE
> var_check_date := TO_DATE(tr_rec.inventory_end_date, YYYYMMDDW); */
> END IF;
>
> I have searched your archives for a similar problem but could not locate
one,
> if I am repeating something that has been answered before, I apologize.
Any
> help or referral to help would be appreciated. Thank you.
>
> Ellen V.
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
>
Received on Wed Dec 09 1998 - 03:56:59 CET