Re: how to test a string for a valid date in sql

From: yossarian <yossarian99_at_operamail.com>
Date: Fri, 11 Dec 2009 11:05:22 +0100
Message-ID: <4b221962$0$702$5fc30a8_at_news.tiscali.it>



Jaap W. van Dijk wrote:

> I'm loading millions of records in a transformation step in a
> datawarehouse with an INSERT INTO ... SELECT ... FROM ... Part of the
> transformation is converting a date-string in a VARCHAR2 column into a
> date in a DATE column, something like
>
> CASE WHEN date-string is valid THEN TO_DATE(date-string) ELSE NULL
> END.
>
> Is it possible to test a string for a valid date in Oracle 9i/10g/11g
> without resorting to PL/SQL? If I use a homemade PL/SQL function, this
> is performed once for each record, which increases the load time
> considerably due to the millions of SQL - PL/SQL context switches back
> and forth.

case when regexp_like(date_string,format_regexp) then to_date(date_string,format_mask) else null Received on Fri Dec 11 2009 - 04:05:22 CST

Original text of this message