void getString()
{
string str = "9823-kko-A";
string target = "-";
int tgtFirst = str.IndexOf(target);
int numFirst = tgtFirst + 1;
int tgtSecond = str.IndexOf(target, numFirst);
int numLast = tgtSecond - 1;
string num = str.Substring(0, 1);
Regex regex = new Regex(@"[0-9]");
if (regex.IsMatch(num))
{
Console.WriteLine(target + "を取り除きました");
Console.WriteLine(str.Substring(0, numFirst - 1));
}
else if (tgtFirst > 0 & tgtSecond > 0)
{
Console.WriteLine(target + "を取り除きました");
Console.WriteLine(str.Substring(numFirst, (numLast - numFirst + 1)));
str = str.Substring(numFirst, (numLast - numFirst + 1));
if (str.Contains(target))
{
numLast = str.Length - str.LastIndexOf(target);
Console.WriteLine(str.Substring(0, numLast));
}
}
else
{
Console.WriteLine(target + "はありません");
Console.WriteLine(str);
}
}
void B_TableMarge()
{
DataTable dt = new DataTable();
TN = "DEPT";
repTN = "R_" + TN + " R";
xbbTN = TN + "@FICUSR X";
bkTN = TN + "_BK";
col1 = "DEPTNO";
whereON =
"R." + col1 + " = X." + col1;
string whereDEL_R = "R." + col1;
string whereDEL_X = "X." + col1;
colNum = 1;
chkdata();
}
void chkdata()
{
DataTable dt = new DataTable();
Console.WriteLine("■BK作成...");
strSql =
"create table " + bkTN +
" as select * from " + TN;
Console.WriteLine(strSql);
DBA_non_dt(strSql);
Console.WriteLine("■差分確認...");
strSql =
"select count(*) from " +
"(select * from " + bkTN +
" minus select * from " + repTN + ")";
Console.WriteLine(strSql);
dt = DBA(strSql);
Console.WriteLine(dt.Rows[0][0] + "件の差分あり\r\n");
if (dt.Rows[0][0].ToString() == "0")
{
Console.WriteLine("差分なし\r\n");
}
else
{
ComFunc();
Console.WriteLine("■差分確認(0になったかどうか)...");
strSql =
"select count(*) from " +
"(select * from " + bkTN +
" minus select * from " + repTN + ")";
Console.WriteLine(strSql);
dt = DBA(strSql);
Console.WriteLine(dt.Rows[0][0] + "件の差分あり\r\n");
repTN = bkTN + " R";
xbbTN = TN + "_BK X";
ComFunc();
}
Console.WriteLine("■BK削除...");
strSql = "drop table " + bkTN;
Console.WriteLine(strSql);
DBA_non_dt(strSql);
}