how to test a string for a valid date in sql

From: Jaap W. van Dijk <>
Date: Fri, 11 Dec 2009 02:01:07 -0800 (PST)
Message-ID: <>

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.

Jaap. Received on Fri Dec 11 2009 - 04:01:07 CST

Original text of this message