public static long SelectLong( string sql, OracleDbType[] parmTypes = null, object[] parmValues = null) { DbCommandMx cmd = DbCommandMx.PrepareExecuteAndRead(sql, parmTypes, parmValues); if (cmd == null) { return(NullValue.NullNumber); } long value = cmd.GetLong(0); cmd.CloseReader(); return(value); }
public static int SelectInt( string sql, OracleDbType parmType, object parmValue) { DbCommandMx cmd = DbCommandMx.PrepareExecuteAndRead( sql, new OracleDbType[] { parmType }, new object[] { parmValue }); if (cmd == null) { return(NullValue.NullNumber); } int value = cmd.GetInt(0); cmd.CloseReader(); return(value); }
public static void UpdateFingerprintFiles() { string msg = ""; long uci, lastUci = 0; int baseFpWriteCnt = 0, fragFpWriteCnt = 0, nullFpCnt = 0, readCnt = 0; int fi = 0; string sql = @" select x.uci, x.src_id, x.src_compound_id, x.src_compound_id_nbr, s.fingerprint, h.fingerprint from DEV_MBS_OWNER.CORP_UC_XREF x, DEV_MBS_OWNER.CORP_UC_STRUCTURE s, DEV_MBS_OWNER.CORP_UC_FIKHB_HIERARCHY h where s.uci = x.uci and H.PARENT (+) = s.fikhb /* and s.uci between 1 and 1000 */ /* debug */ order by s.uci" ; ShowProgress("Executing select fingerprints query..."); DbCommandMx cmd = DbCommandMx.PrepareExecuteAndRead(sql); if (cmd == null) { throw new Exception("No rows retrieved"); } bool readOk = true; BinaryWriter[] bw = FpDao.OpenFingerprintFilesForWriting(); fi = 0; DateTime lastProgressUpdate = DateTime.Now; while (true) { if (readCnt > 0) // read next row if not first row { readOk = cmd.Read(); } if (readOk) { readCnt++; } if (DateTime.Now.Subtract(lastProgressUpdate).TotalSeconds > 1 || !readOk) // show progress { lastProgressUpdate = DateTime.Now; int fpWriteCnt = baseFpWriteCnt + fragFpWriteCnt; msg = "Update Fingerprint Files\r\n" + "\r\n" + "Reads: " + readCnt + "\r\n" + "Fingerprints written: " + fpWriteCnt + "\r\n" + "Null FPs: " + nullFpCnt; ShowProgress(msg); } if (!readOk) { break; } uci = cmd.GetLong(0); int src = cmd.GetInt(1); string cidString = cmd.GetString(2); int cidInt = cmd.GetInt(3); byte[] fp = cmd.GetBinary(4); byte[] fp2 = cmd.GetBinary(5); if (fp == null && fp2 == null) { nullFpCnt++; continue; } if (uci != lastUci) { fi = (fi + 1) % FpDao.FingerprintFileCount; lastUci = uci; } if (fp != null) { FpDao.WriteFingerprintRec(bw[fi], uci, src, cidString, fp); baseFpWriteCnt++; } if (fp2 != null) { FpDao.WriteFingerprintRec(bw[fi], uci, src, cidString, fp2); fragFpWriteCnt++; } } // read loop cmd.CloseReader(); FpDao.CloseFingerprintFilesForWriting(); FpDao.BackupAndReplaceFingerprintFiles(); msg = "*** Update Complete ***\r\n\r\n" + msg; ShowProgress(msg); return; }