码迷,mamicode.com
首页 > 其他好文 > 详细

etl 获取列数据类型

时间:2016-01-04 23:59:28      阅读:441      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!