All Forums Database
jpw111082 1 post Joined 06/16
30 Jun 2016
Error when trying to create a function

Hi, I am trying to create my first function in Teradata SQL Assistant using a script I found on the internet.  the purpose of the function is to convert a timestamp to a unix timestamp and is as follows;
 
CREATE OR REPLACE FUNCTION oracle_to_unix(in_date IN DATE) RETURN NUMBER 
IS 
BEGIN 
  RETURN (in_date -TO_DATE('19700101','yyyymmdd'))*86400 -   TO_NUMBER(SUBSTR(TZ_OFFSET(sessiontimezone),1,3)) *3600; END;
 
when I try to run this sql I get the error "Data Type "in_data" does not mata Defined Data type.  

dnoeth 4628 posts Joined 11/04
30 Jun 2016

This is Oracle source code, of course it's not working as-is on Teradata.
See http://forums.teradata.com/forum/general/convert-13-digit-epoch-time-to-date#comment-148179 for an example to cast a Timestamp to epoch time.

Dieter

You must sign in to leave a comment.