unote 書けば書くほどに

20230213

// 検証
//テーブル関数内に作成:検証関数

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();

    //_BK作成
    Console.WriteLine("■BK作成...");
    strSql =
        "create table " + bkTN +
        " as select * from " + TN;
    Console.WriteLine(strSql);
    DBA_non_dt(strSql);//★置き換え必要★

    //minus:差分確認
    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();//update関数を実行

        //minus:差分確認(0になったかどうか)
        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");

        //BKを更新後のレプリカでupdate
        repTN = bkTN + " R";//対象を入替
        xbbTN = TN + "_BK X";//対象を入替
        ComFunc();//update関数を実行

    }

    //_BK削除
    Console.WriteLine("■BK削除...");
    strSql = "drop table " + bkTN;
    Console.WriteLine(strSql);
    DBA_non_dt(strSql);//★置き換え必要★

}