Exemple #1
0
        private int BuildAndExecuteDeleteSQLStmts(OleDbConnection oConn, string table, string column)
        {
            var matchedRecordCount = (int)m_ado.getSingleDoubleValueFromSQLQuery(oConn,
                                                                                 String.Format("SELECT COUNT(*) FROM {0} WHERE {1} IN ({2});", table, column, m_strPackageNumbers),
                                                                                 table);

            if (matchedRecordCount == 0)
            {
                return(0);
            }

            var deleteSQL = String.Format("DELETE FROM {0} WHERE {1} IN ({2});", table, column, m_strPackageNumbers);

            if (frmMain.g_bDebug && frmMain.g_intDebugLevel > 2)
            {
                var message = Checked(chkDeletesDisabled)
                    ? "Generated but not executed: " + deleteSQL + "\r\n"
                    : "Attempting to execute: " + deleteSQL + "\r\n";
                frmMain.g_oUtils.WriteText(m_strDebugFile, message);
            }
            if (!Checked(chkDeletesDisabled))
            {
                m_ado.SqlNonQuery(oConn, deleteSQL);
            }
            return(matchedRecordCount);
        }
        private int BuildAndExecuteDeleteSQLStmts(OleDbConnection oConn, string table, string column)
        {
            int    matchedRecordCount = 0;
            string columnKey          = column;

            string[] edgeCaseTables = { "fcs_biosum_volumes_input" };

            if (edgeCaseTables.Contains(table))
            {
                //FCS schema uses cnd_cn/plt_cn, but we set these values to biosum_cond_id/biosum_plot_id in FVSOUT stage
                if (table.ToLower() == "fcs_biosum_volumes_input" && column.ToLower() == "cnd_cn")
                {
                    columnKey = "biosum_cond_id";
                }
            }

            var batches = m_dictIdentityColumnsToValues[columnKey]
                          .Select((id, i) => new { id, i })
                          .GroupBy(p => p.i / 100, p => p.id);

            foreach (var batch in batches)
            {
                var values = string.Join(",", batch);
                matchedRecordCount += (int)m_ado.getSingleDoubleValueFromSQLQuery(oConn,
                                                                                  String.Format("SELECT COUNT(*) FROM {0} WHERE {1} IN ({2});", table, column, values), table);
                var deleteSQL = String.Format("DELETE FROM {0} WHERE {1} IN ({2});", table, column, values);
                if (frmMain.g_bDebug && frmMain.g_intDebugLevel > 2)
                {
                    var message = Checked(chkDeletesDisabled)
                        ? "Generated but not executed: " + deleteSQL + "\r\n"
                        : "Attempting to execute: " + deleteSQL + "\r\n";
                    frmMain.g_oUtils.WriteText(m_strDebugFile, message);
                }

                if (!Checked(chkDeletesDisabled))
                {
                    m_ado.SqlNonQuery(oConn, deleteSQL);
                }
            }

            return(matchedRecordCount);
        }