Thanks Anoop for the help again :) Yes, I forgot CAST … 发件人: Anoop Sharma [mailto:anoop.sha...@esgyn.com] 发送时间: 2016年3月30日 22:04 收件人: user@trafodion.incubator.apache.org 主题: RE: converting INTEGER to CHAR in Trafodion
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....@esgyn.cn] Sent: Wednesday, March 30, 2016 5:12 AM To: user@trafodion.incubator.apache.org<mailto: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