i want table creation script on teradata jdbc. used code found on stackoverflow :
stringbuilder sb = new stringbuilder( 1024 ); if ( columncount > 0 ) { sb.append( "create table ").append( rsmd.gettablename( 1 ) ).append( " ( " ); } ( int = 1; <= columncount; ++ ) { if ( > 1 ) sb.append( ", " ); string columnname = rsmd.getcolumnlabel( ); string columntype = rsmd.getcolumntypename( ); sb.append( columnname ).append( " " ).append( columntype ); int precision = rsmd_ddl.getprecision( ); if ( precision != 0 ) { sb.append( "( " ).append( precision ).append( " )" ); } } // columns sb.append( " ) " );
but problem : when type varchar
precision 0
in teradata column varchar(100)
how can find 100
?
thanks.
getprecision decimals, should use getcolumndisplaysize chars.
there lots of samples in teradata jdbc reference: http://developer.teradata.com/doc/connectivity/jdbc/reference/current/frameset.html
sample t20100jd shows how ectract metadata.
Comments
Post a Comment