public List <IConstraintClass> GetConstraints() { if (_constraints.Count == 0 && !_isLoadCons) { StringBuilder sb = new StringBuilder(); sb.Append(" create or replace function user_cons_long_2_varchar(p_table_name in user_constraints.constraint_name%type)"); sb.Append(" return varchar2 as"); sb.Append(" l_search_condition LONG;"); sb.Append(" begin"); sb.Append(" select search_condition"); sb.Append(" into l_search_condition"); sb.Append(" from user_constraints"); sb.Append(" where constraint_name = p_table_name;"); sb.Append(" return substr(l_search_condition, 1, 40000);"); sb.Append(" end;"); _oracleHelper.ExecuteSql(sb.ToString());//添加函数 string sql = "select t.constraint_name,t.constraint_type,t.table_name,user_cons_long_2_varchar(t.constraint_name) as search_condition,t.r_constraint_name,t.delete_rule,t.status,t.validated,t.index_name from user_constraints t,user_tables t1 where t.table_name=t1.table_name and generated='USER NAME' order by t.constraint_name"; DataTable dt = _oracleHelper.ExecuteDataTable(sql); _oracleHelper.ExecuteSql("drop function user_cons_long_2_varchar"); foreach (DataRow item in dt.Rows) { OracleConstraintClass occ = new OracleConstraintClass(item); occ.SetOracleHelper(_oracleHelper); _constraints.Add(occ); } _isLoadCons = true; } List <IConstraintClass> t = new List <IConstraintClass>(); t.AddRange(_constraints); return(t); }
internal void DoLoadCons() { if (!_isLoadCos) { string type = Convert.ToString(constraint_type); if (_oracleHelper != null && oracleConstraintClass == null && type == "R") { StringBuilder sb = new StringBuilder(); sb.Append(" create or replace function user_cons_long_2_varchar(p_table_name in user_constraints.constraint_name%type)"); sb.Append(" return varchar2 as"); sb.Append(" l_search_condition LONG;"); sb.Append(" begin"); sb.Append(" select search_condition"); sb.Append(" into l_search_condition"); sb.Append(" from user_constraints"); sb.Append(" where constraint_name = p_table_name;"); sb.Append(" return substr(l_search_condition, 1, 4000);"); sb.Append(" end;"); _oracleHelper.ExecuteSql(sb.ToString());//添加函数 string sql = "select t.constraint_name,t.constraint_type,t.table_name,user_cons_long_2_varchar(t.constraint_name) as search_condition,t.r_constraint_name,t.delete_rule,t.status,t.validated,t.index_name from user_constraints t,user_tables t1 where t.table_name=t1.table_name and generated='USER NAME' and constraint_name='" + r_constraint_name + "'"; DataTable dt = _oracleHelper.ExecuteDataTable(sql); _oracleHelper.ExecuteSql("drop function user_cons_long_2_varchar"); if (dt.Rows.Count > 0) { oracleConstraintClass = new OracleConstraintClass(dt.Rows[0]); oracleConstraintClass.SetOracleHelper(_oracleHelper); } } _isLoadCos = true; } }
public List<IConstraintClass> GetConstraints() { if (_constraints.Count == 0 && !_isLoadCons) { StringBuilder sb = new StringBuilder(); sb.Append(" create or replace function user_cons_long_2_varchar(p_table_name in user_constraints.constraint_name%type)"); sb.Append(" return varchar2 as"); sb.Append(" l_search_condition LONG;"); sb.Append(" begin"); sb.Append(" select search_condition"); sb.Append(" into l_search_condition"); sb.Append(" from user_constraints"); sb.Append(" where constraint_name = p_table_name;"); sb.Append(" return substr(l_search_condition, 1, 40000);"); sb.Append(" end;"); _oracleHelper.ExecuteSql(sb.ToString());//添加函数 string sql = "select t.constraint_name,t.constraint_type,t.table_name,user_cons_long_2_varchar(t.constraint_name) as search_condition,t.r_constraint_name,t.delete_rule,t.status,t.validated,t.index_name from user_constraints t,user_tables t1 where t.table_name=t1.table_name and generated='USER NAME' order by t.constraint_name"; DataTable dt = _oracleHelper.ExecuteDataTable(sql); _oracleHelper.ExecuteSql("drop function user_cons_long_2_varchar"); foreach (DataRow item in dt.Rows) { OracleConstraintClass occ = new OracleConstraintClass(item); occ.SetOracleHelper(_oracleHelper); _constraints.Add(occ); } _isLoadCons = true; } List<IConstraintClass> t = new List<IConstraintClass>(); t.AddRange(_constraints); return t; }