You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@trafodion.apache.org by 韦俊鲁 <we...@teamsun.com.cn> on 2017/12/13 02:14:34 UTC

question about interval data type

 question about interval data type

                 create a table with interval year column, and query it by jdbc interface, and the column type in the result is interval?why not interval year?

stmt = connection.createStatement();
stmt.execute("drop table trafodion.seabase.test_intervalyear");
stmt.execute("create table trafodion.seabase.test_intervalyear(c1 interval year)");
DatabaseMetaData dbmd = connection.getMetaData();
rs = dbmd.getColumns("TRAFODION", "SEABASE", "TEST_INTERVALYEAR", "%");
int colnum = 8;//rs.getMetaData().getColumnCount();
String colname = null;
for (int i=1; i<=colnum; i++) {
    colname = rs.getMetaData().getColumnName(i);
    System.out.print(colname);
    System.out.print(", ");
if (colname == null) {
for (int j=0; j<10; j++) {
            System.out.print(" ");
        }
    } else {
for (int j = 0; j < (16 - colname.length()); j++) {
            System.out.print(" ");
        }
    }
}
System.out.println();
while (rs.next()) {
for (int i=1; i<=colnum; i++) {
        colname = rs.getString(i);
        System.out.print(colname);
        System.out.print(", ");
if (colname == null) {
for (int j=0; j<10; j++) {
                System.out.print(" ");
            }
        } else {
for (int j = 0; j < (16 - colname.length()); j++) {
                System.out.print(" ");
            }
        }
    }
    System.out.println();


}    

result:

TABLE_CAT,        TABLE_SCHEM,      TABLE_NAME,             COLUMN_NAME,      DATA_TYPE,        TYPE_NAME,        COLUMN_SIZE,      BUFFER_LENGTH,    


TRAFODION,        SEABASE,          TEST_INTERVALYEAR,     C1,                            101,                      INTERVAL,             1,                           34,  

RE: question about interval data type

Posted by Selva Govindarajan <se...@esgyn.com>.
Currently, JDBC Standard has no standard mapping for INTERVAL data types. ODBC has support for interval data type.  Trafodion has inherited this mapping from the legacy code when the ODBC/JDBC specification didn't support interval data types. This needs to be updated with the current standard specification.  Yes, it is possible to change the type name to 

INTERVAL YEAR
INTERVAL MONTH
INTERVAL YEAR TO MONTH 
INTERVAL DAY
INTERVAL DAY TO MINUTE
INTERVAL HOUR
INTERVAL DAY TO SECOND +
INTERVAL MINUTE
INTERVAL HOUR TO MINUTE
INTERVAL SECOND
INTERVAL HOUR TO SECOND
INTERVAL DAY TO HOUR
INTERVAL MINUTE TO SECOND

depending upon the SQL data type.  Please feel free to file a JIRA and consider volunteering to contribute to Trafodion.

Selva

-----Original Message-----
From: 韦俊鲁 [mailto:weijl@teamsun.com.cn] 
Sent: Tuesday, December 12, 2017 6:15 PM
To: dev <de...@trafodion.incubator.apache.org>
Subject: question about interval data type

 question about interval data type

                 create a table with interval year column, and query it by jdbc interface, and the column type in the result is interval?why not interval year?

stmt = connection.createStatement();
stmt.execute("drop table trafodion.seabase.test_intervalyear");
stmt.execute("create table trafodion.seabase.test_intervalyear(c1 interval year)"); DatabaseMetaData dbmd = connection.getMetaData(); rs = dbmd.getColumns("TRAFODION", "SEABASE", "TEST_INTERVALYEAR", "%"); int colnum = 8;//rs.getMetaData().getColumnCount();
String colname = null;
for (int i=1; i<=colnum; i++) {
    colname = rs.getMetaData().getColumnName(i);
    System.out.print(colname);
    System.out.print(", ");
if (colname == null) {
for (int j=0; j<10; j++) {
            System.out.print(" ");
        }
    } else {
for (int j = 0; j < (16 - colname.length()); j++) {
            System.out.print(" ");
        }
    }
}
System.out.println();
while (rs.next()) {
for (int i=1; i<=colnum; i++) {
        colname = rs.getString(i);
        System.out.print(colname);
        System.out.print(", ");
if (colname == null) {
for (int j=0; j<10; j++) {
                System.out.print(" ");
            }
        } else {
for (int j = 0; j < (16 - colname.length()); j++) {
                System.out.print(" ");
            }
        }
    }
    System.out.println();


}    

result:

TABLE_CAT,        TABLE_SCHEM,      TABLE_NAME,             COLUMN_NAME,      DATA_TYPE,        TYPE_NAME,        COLUMN_SIZE,      BUFFER_LENGTH,    


TRAFODION,        SEABASE,          TEST_INTERVALYEAR,     C1,                            101,                      INTERVAL,             1,                           34,