trafodion-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Birdsall <dave.birds...@esgyn.com>
Subject RE: How to get date from sqlci in binary format
Date Thu, 24 Mar 2016 15:42:01 GMT
Hi Weiqing,

Can you say more about what you mean by "binary format"? For example, are
you looking for a value such as the Unix/Linux time() function returns?

Dave

-----Original Message-----
From: Hans Zeller [mailto:hans.zeller@esgyn.com]
Sent: Thursday, March 24, 2016 12:06 AM
To: dev <dev@trafodion.incubator.apache.org>
Subject: Re: How to get date from sqlci in binary format

Hi again,

Sorry, no, I don't know how to prevent that conversion to a string from
happening. As far as I know, the CLI will always transfer datetime values as
a string.

Hans

On Wed, Mar 23, 2016 at 11:56 PM, Weiqing Xu <xuweiqingchn@gmail.com> wrote:

> H Hans,
>
> Thanks for your quickly response.
>
> But I want to get the Binary datetime from the sqlcli directly rather
> than converting it in jdbc driver layer.
>
> In JDBC T2 , it use CLI_SetDescItem() to get the data from sqlcli.
> When give the parameter "SQLDESC_VAR_PTR", it will get the value of the
> item.
> Now , JDBC T2 will get a string format datetime through this function .
> What I want to do is getting the binary datetime from this function.
> Do you have any idea?
>
> Best Regards,
> Weiqing
>
> On Thu, Mar 24, 2016 at 2:35 PM, Hans Zeller <hans.zeller@esgyn.com>
> wrote:
>
> > Hi Weiqing,
> >
> > Here is a code fragment from the UDF code that converts a string to
> > the Java "Date" type, taken from
> >
> >
> https://github.com/apache/incubator-trafodion/blob/master/core/sql/src
> /main/java/org/trafodion/sql/udr/TupleInfo.java
> >
> >             Date resultDate;
> >
> >             String val = getString(colNum);
> >             if (wasNull_)
> >                 return new Date(0);
> >             DateFormat df;
> >
> >             try {
> >                 switch (t.getSQLType())
> >                 {
> >                 case DATE:
> >                     // yyyy-mm-dd
> >                     df = new SimpleDateFormat ("yyyy-MM-dd");
> >                     resultDate = df.parse(val);
> >                     break;
> >
> >                 case TIME:
> >                     df = new SimpleDateFormat ("HH:mm:ss");
> >                     resultDate = df.parse(val);
> >                     break;
> >
> >                 case TIMESTAMP:
> >                     df = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss");
> >                     resultDate = df.parse(val);
> >                     break;
> >
> >                 default:
> >                     throw new UDRException(38900,
> >                                            "getTime() not supported
> > for
> SQL
> > type %d",
> >                                            t.getSQLType().ordinal());
> >                 }
> >             }
> >             catch (java.text.ParseException e1) {
> >                 throw new UDRException(
> >                                        38900,
> >                                        "Unable to parse datetime
> > string
> %s
> > for conversion to Date",
> >                                        val);
> >             }
> >
> >
> >
> > Note that some of the enums, Exceptions and variables won't match
> > your case, but I hope the general idea is useful.
> >
> > Hans
> >
> > On Wed, Mar 23, 2016 at 11:27 PM, Weiqing Xu
> > <xuweiqingchn@gmail.com>
> > wrote:
> >
> > > Hi All,
> > >
> > > As default, sqlcli return DATE value in *String format* in JDBC T2
> > Driver.
> > > I want to get the DATE in Binary format since MT-DCS need use JDBC
> > > t2 Driver.
> > >
> > > Does anyone know how to do it ?
> > >
> > > By the way, mxosrvr get the DATE value as Binary from SQLCLI , so
> > > I
> think
> > > it's possible as jdbc t2 too.
> > >
> > > Best Regards,
> > > Weiqing
> > >
> >
>

Mime
View raw message