![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hello, I need to cleanse some data. Some of the data consists of CHARs of the form '2006-12-24' which are to be converted to DATE values. Some of the values are known to be invalid (such as '0000-00-00' or '2006-02-45'), and those values need to be converted to NULLs. So I'm looking for a "CASTLESCE" function: Cast to a type; if the cast fails, return NULL. My first thought was to create a UDF where the UDF catches cast-errors via a declared continue-handler. But using a continue-handler seems to be possible only in procedures(?). What's my best option? Try using a procedure, or in some other way? You can use a SQL UDF that calls a procedure.. |
#3
| |||
| |||
|
|
What's my best option? Try using a procedure, or in some other way? You can use a SQL UDF that calls a procedure.. You won't get a prize for performance though.... |
#4
| |||
| |||
|
|
On Fri, 09 Feb 2007 08:22:38 -0500, Serge Rielau wrote: What's my best option? Try using a procedure, or in some other way? You can use a SQL UDF that calls a procedure.. You won't get a prize for performance though.... How bad is it - will it be more rational to dump the data, massage it procedurally (e.g. with perl), and then import it again? *lol* No it will be better than that... |
#5
| |||
| |||
|
|
What's my best option? Try using a procedure, or in some other way? |
#6
| |||
| |||
|
|
What's my best option? Try using a procedure, or in some other way? You should use an external UDF. For example, in java it whould be fairly simple code. |
#7
| |||
| |||
|
|
Hello, I need to cleanse some data. Some of the data consists of CHARs of the form '2006-12-24' which are to be converted to DATE values. Some of the values are known to be invalid (such as '0000-00-00' or '2006-02-45'), and those values need to be converted to NULLs. |
#8
| |||
| |||
|
|
Yes. But I'm afraid of external UDFs: - are external UDFs backed up when the database is backed up? (using TSM) |
|
- what will happen if/when we upgrade from DB2 v. 8 to v. 9? |
#9
| |||
| |||
|
|
Hello, I need to cleanse some data. Some of the data consists of CHARs of the form '2006-12-24' which are to be converted to DATE values. Some of the values are known to be invalid (such as '0000-00-00' or '2006-02-45'), and those values need to be converted to NULLs. So I'm looking for a "CASTLESCE" function: Cast to a type; if the cast fails, return NULL. My first thought was to create a UDF where the UDF catches cast-errors via a declared continue-handler. But using a continue-handler seems to be possible only in procedures(?). What's my best option? Try using a procedure, or in some other way? |
#10
| |||
| |||
|
|
If there are just a few of such values, then maybe NULLIF is a way to go? |
![]() |
| Thread Tools | |
| Display Modes | |
| |