Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Oracle to Teradata, How can I use decode and ifnull-datetime functions

Status
Not open for further replies.

daiglep

Programmer
Jun 25, 2003
1
CA
Converting data from Oracle to teradata. I have an application right now that uses the Oracle functions decode and ifnull-datetime.

Is there a way to create User Defined Functions in Teradata called decode and ifnull-datetime that will perform the same way as these functions do in Oracle? Can you create functions in Teradata? Sorry, I am new to teradata.
 
You can't write UDFs yet (you'll have to wait for V2R5.1), but you can replace the proprietary Decode with CASE, which is ANSI compliant and much more versatile,
e.g.
decode(foo,
1, 'bar',
2, 'bla',
'xx')
is equivalent to

case foo
when 1 then 'bar'
when 2 then 'bla'
else 'xx'
end

This is a "Valued Case", but you can do a complex "Searched Case" like:
case
when col1 > 23 and col2 in (1,2,3) then 'foo'
when col4 like 'b%' or col5 is not null then 'bla'
else 'xx'
end

Sorry about IfNull, i don't know that function, but sounds similar to NVL, so it's probably just another Case or the abbreviations for Case: Coalesce/NullIf.

Btw, IIRC Oracle supports Case since 8.1.7

Dieter
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top