首页 > 其他 > 详细

etl 获取列数据类型

时间:2016-01-04 23:57:56      阅读:458      评论:0      收藏:0      [点我收藏+]

QueryInfo info = new QueryInfo();
info.CustomSQL = @" select
column_name,
data_type,
data_precision,
data_scale,
nvl((select t_s.comments
from all_col_comments t_s
where t_s.column_name = t.column_name
and t_s.table_name =‘ccr_company_fundamental‘
),column_name)
comments
from all_tab_columns t
where
table_name = upper(‘ccr_company_fundamental‘)
and data_type=‘NUMBER‘";
DataTable table1 = Dao.ExcuteDataSet(info).Tables[0];
StringBuilder sb1 = new StringBuilder();
string type = "";
int scale = 0;
string real_type = "";
int index = 0;
string column_name = "";
foreach (DataRow row in table1.Rows)
{
column_name = row["COLUMN_NAME"].ToString();
type = row["DATA_TYPE"].ToString();
int.TryParse(row["data_scale"].ToString(), out scale);

switch (type)
{
case "NUMBER":
if (scale <= 0)
sb1.AppendLine(string.Format("new Excel2DataMap {{ MapIndex ={0}, ColumnName = ‘{1}‘, DataType = ConstEnum.DataTypeDimesion.整形 }},", index++, column_name));
else
{
sb1.AppendLine(string.Format("(new Excel2DataMap {{ MapIndex ={0}, ColumnName = \"{1}\", DataType = ConstEnum.DataTypeDimesion.浮点型 }}),", index++, column_name));
}
break;

case "NVARCHAR2":
case "VARCHAR2":
sb1.AppendLine(string.Format("(new Excel2DataMap {{ MapIndex ={0}, ColumnName = \"{1}\", DataType = ConstEnum.DataTypeDimesion.字符串 }}),", index++, column_name));
break;
case "DATE":
sb1.AppendLine(string.Format("(new Excel2DataMap {{ MapIndex ={0}, ColumnName = \"{1}\", DataType = ConstEnum.DataTypeDimesion.日期 }}),", index++, column_name));
break;


}


}

 

return;

etl 获取列数据类型

原文:http://www.cnblogs.com/kexb/p/5100566.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!