You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@trafodion.apache.org by "Liu, Ming (Ming)" <mi...@esgyn.cn> on 2016/03/30 14:11:59 UTC

converting INTEGER to CHAR in Trafodion

Hi, all,

I know it will be much easier to do in C or Java after get the result set, but the Oracle users are used to use to_char() function. Is there similar function in Trafodion?

Or maybe we can write a UDF for it, but the problem of UDF is it cannot support polymorphism, that is, one can only define the syntax/signature of a UDF once, is it true?
For example, it cannot define a TO_CHAR that can :
TO_CHAR(123), return is '123'.
TO_CHAR(date'2001/11/11','YYYY/MM/DD'), return is '2001-11-11'.

Seems rather difficult to replace Oracle's TO_CHAR completely.

Or I miss something? Thanks in advance.

Thanks,
Ming




RE: converting INTEGER to CHAR in Trafodion

Posted by Anoop Sharma <an...@esgyn.com>.
Trafodion supports to_date and to_char to convert datetime  values from
string to datetime, or datetime to string.

It does not support all of oracle to_date/to_char functionality/formats, but
a subset of it.

One can also use CAST function to convert from numeric from/to string.

 

For the 2 examples, you can use to_char to convert from DATE to string. 

And use CAST to convert from numeric to string.

 

>>select to_char(date '2016-10-10', 'YYYY/MM/DD') from (values(1)) X(a);

 

(EXPR)    

----------

 

2016/10/10

 

--- 1 row(s) selected.

>>select cast(123 as char(3)) from (values(1)) x(a);

 

(EXPR)

------

 

123   

 

--- 1 row(s) selected.

>> 

 

From: Liu, Ming (Ming) [mailto:ming.liu@esgyn.cn] 
Sent: Wednesday, March 30, 2016 5:12 AM
To: user@trafodion.incubator.apache.org
Subject: converting INTEGER to CHAR in Trafodion

 

Hi, all,

 

I know it will be much easier to do in C or Java after get the result set,
but the Oracle users are used to use to_char() function. Is there similar
function in Trafodion? 

 

Or maybe we can write a UDF for it, but the problem of UDF is it cannot
support polymorphism, that is, one can only define the syntax/signature of a
UDF once, is it true? 

For example, it cannot define a TO_CHAR that can :

TO_CHAR(123), return is '123'. 

TO_CHAR(date'2001/11/11','YYYY/MM/DD'), return is '2001-11-11'. 

 

Seems rather difficult to replace Oracle's TO_CHAR completely.

 

Or I miss something? Thanks in advance.

 

Thanks,

Ming