Example #1
0
        public string GetRevisionLastUpdate()
        {
            string result = string.Empty;

            try
            {
                ProcParam param = new ProcParam(1)
                {
                    ProcedureName = "INTERFACE_PACK.RET_LAST_REV"
                };
                param.AddParamReturn(0, "ReturnValue", Oracle.DataAccess.Client.OracleDbType.Date, 255);

                GlobalDB.Instance.DataAc.ExecuteNonQuery(param);
                //this.executionTime = GlobalDB.Instance.DataAc.ExecuteTime;

                object oResult = param.ReturnValue(0);
                if (!oResult.Equals(DBNull.Value))
                {
                    OracleDate resultDB = (OracleDate)oResult;
                    if (!resultDB.IsNull)
                    {
                        result = resultDB.Value.ToString("dd-MM-yyyy HH:mm:ss");
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(result);
        }
Example #2
0
        public double ZmianaKoordynatora(string funkcja, string imie, string nazwisko, string poczatek)
        {
            double suma = 0;

            try
            {
                conn.Open();
                OracleCommand cmd = conn.CreateCommand();

                cmd.CommandText = "KPiR.ZMIANA_KOORDYNATORA";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("funkcja", OracleDbType.Varchar2).Value  = funkcja;
                cmd.Parameters.Add("imie", OracleDbType.Varchar2).Value     = imie;
                cmd.Parameters.Add("nazwisko", OracleDbType.Varchar2).Value = nazwisko;
                OracleDate date = new OracleDate(int.Parse(poczatek.Substring(0, 4)), int.Parse(poczatek.Substring(5, 2)), int.Parse(poczatek.Substring(8, 2)));
                cmd.Parameters.Add("poczatek", OracleDbType.Date).Value = date;
                cmd.ExecuteNonQuery();
                cmd.Parameters.RemoveAt(0);
                conn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            if (conn.State != ConnectionState.Closed)
            {
                conn.Close();
            }
            return(suma);
        }
Example #3
0
        public double getStanKonta(string nazwa, string data)
        {
            double suma = 0;

            try
            {
                conn.Open();
                OracleCommand cmd = conn.CreateCommand();

                cmd.CommandText = "KPiR.STAN_KONTA";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("Return_Value", OracleDbType.Double, ParameterDirection.ReturnValue);
                cmd.Parameters.Add("NAZWA", OracleDbType.Varchar2).Value = nazwa;
                OracleDate date = new OracleDate(int.Parse(data.Substring(0, 4)), int.Parse(data.Substring(5, 2)), int.Parse(data.Substring(8, 2)));
                cmd.Parameters.Add("DATA", OracleDbType.Date).Value = date;
                cmd.ExecuteNonQuery();
                suma = double.Parse(cmd.Parameters["Return_Value"].Value.ToString().Replace(".", ","));
                cmd.Parameters.RemoveAt(0);
                conn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            if (conn.State != ConnectionState.Closed)
            {
                conn.Close();
            }
            return(suma);
        }
Example #4
0
 public static TokenData GetData(string tokenId)
 {
     try
     {
         TokenData        data       = new TokenData();
         Guid             guid       = new Guid(tokenId);
         OracleConnection connection = new OracleConnection("DATA SOURCE=ISE;PASSWORD=ise3a9aram;PERSIST SECURITY INFO=True;USER ID=isebase");
         OracleCommand    command    = new OracleCommand {
             Connection  = connection,
             CommandType = CommandType.StoredProcedure,
             CommandText = "GetRemoteToken"
         };
         command.Parameters.Add("id", OracleDbType.Varchar2, 0x20).Value             = tokenId.ToUpper();
         command.Parameters.Add("nationalCode", OracleDbType.Varchar2, 12).Direction = ParameterDirection.Output;
         command.Parameters.Add("personelCode", OracleDbType.Varchar2, 12).Direction = ParameterDirection.Output;
         command.Parameters.Add("expiredTime", OracleDbType.Date).Direction          = ParameterDirection.Output;
         command.Parameters.Add("appCode", OracleDbType.Int32).Direction             = ParameterDirection.Output;
         connection.Open();
         command.ExecuteScalar();
         data.NationalCode = command.Parameters["nationalCode"].Value.ToString();
         data.PersonelCode = command.Parameters["personelCode"].Value.ToString();
         OracleDate date = (OracleDate)command.Parameters["expiredTime"].Value;
         data.ExpiredDate = new DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second);
         data.AppCode     = Convert.ToInt16(command.Parameters["appCode"].Value.ToString());
         connection.Close();
         connection.Dispose();
         command.Dispose();
         return(data);
     }
     catch (Exception)
     {
         return(null);
     }
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="format"></param>
        /// <param name="date"></param>
        /// <param name="dateTime"></param>
        /// <returns></returns>
        protected internal bool ConvertToDateTimeFromOracleInternal(OracleDateTimeFormat format, object date, out DateTime dateTime)
        {
            dateTime = DateTime.MinValue;
            if (date == null)
            {
                return(false);
            }

            try
            {
                switch (format)
                {
                case OracleDateTimeFormat.ORACLE_DATE:
                    var oracleDate = new OracleDate((string)date);
                    if (oracleDate != OracleDate.Null)
                    {
                        dateTime = oracleDate.Value;
                    }
                    break;

                case OracleDateTimeFormat.ORACLE_TIMESTAMP:
                    var oracleTSDate = new OracleTimeStamp((string)date);
                    if (oracleTSDate != OracleTimeStamp.Null)
                    {
                        dateTime = oracleTSDate.Value;
                    }
                    break;

                case OracleDateTimeFormat.ORACLE_TIMESTAMP_TZ:
                    var oracleTSZDate = new OracleTimeStampTZ((string)date);
                    if (oracleTSZDate != OracleTimeStampTZ.Null)
                    {
                        dateTime = oracleTSZDate.Value;
                    }
                    break;

                case OracleDateTimeFormat.ORACLE_TIMESTAMP_LTZ:
                    var oracleLTSZDate = new OracleTimeStampLTZ((string)date);
                    if (oracleLTSZDate != OracleTimeStampLTZ.Null)
                    {
                        dateTime = oracleLTSZDate.Value;
                    }
                    break;

                default:
                    throw new ApplicationException("Invalid format specified");
                }
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }
Example #6
0
    private static void CallProcedure(OracleConnection conn)
    {
        try
        {
            var           sql = "Get_Employee_Info";
            OracleCommand cmd = new OracleCommand(sql, conn);
            // Видом Command является StoredProcedure
            cmd.CommandType = CommandType.StoredProcedure;
            // Добавить параметр @p_Emp_Id и настроить его значение = 100.
            cmd.Parameters.Add("@p_Emp_Id", OracleDbType.Int32).Value = 100;

            // Добавить параметр @v_Emp_No вида Varchar(20).
            cmd.Parameters.Add(new OracleParameter("@v_Emp_No", OracleDbType.Varchar2, 20));
            cmd.Parameters.Add(new OracleParameter("@v_First_Name", OracleDbType.Varchar2, 50));
            cmd.Parameters.Add(new OracleParameter("@v_Last_Name", OracleDbType.Varchar2, 50));
            cmd.Parameters.Add(new OracleParameter("@v_Hire_Date", OracleDbType.Date));

            // Зарегистрировать параметр @v_Emp_No как OUTPUT.
            cmd.Parameters["@v_Emp_No"].Direction     = ParameterDirection.Output;
            cmd.Parameters["@v_First_Name"].Direction = ParameterDirection.Output;
            cmd.Parameters["@v_Last_Name"].Direction  = ParameterDirection.Output;
            cmd.Parameters["@v_Hire_Date"].Direction  = ParameterDirection.Output;

            // Выполнить процедуру.
            cmd.ExecuteNonQuery();

            // Получить выходные значения.
            string empNo       = cmd.Parameters["@v_Emp_No"].Value.ToString();
            string firstName   = cmd.Parameters["@v_First_Name"].Value.ToString();
            string lastName    = cmd.Parameters["@v_Last_Name"].Value.ToString();
            object hireDateObj = cmd.Parameters["@v_Hire_Date"].Value;

            Console.WriteLine("hireDateObj type: " + hireDateObj.GetType().ToString());
            OracleDate hireDate = (OracleDate)hireDateObj;


            Console.WriteLine("Emp No: " + empNo);
            Console.WriteLine("First Name: " + firstName);
            Console.WriteLine("Last Name: " + lastName);
            Console.WriteLine("Hire Date: " + hireDate);
        }
        catch (Exception e)
        {
            Console.WriteLine(e);
            throw;
        }
        finally
        {
            conn.Clone();
            conn.Dispose();
            conn = null;
        }
    }
Example #7
0
 protected override void FromOracleParamInternal(OracleParameter param)
 {
     if (IsNull(param.Value) == true)
     {
         ParamValue = null;
     }
     else
     {
         OracleDate date = (OracleDate)param.Value;
         ParamValue = date.Value;
     }
 }
        public void TestGetNullableDateTimeValue()
        {
            DateTime TempDateTime = DateTime.Now;
            OracleDate Date1 = OracleDate.Null;
            OracleDate Date2 = new OracleDate(TempDateTime);

            DateTime? DateA = FieldConverter.GetNullableDateTimeValue(Date1);
            DateTime? DateB = FieldConverter.GetNullableDateTimeValue(Date2);

            Assert.AreEqual(false, DateA.HasValue);
            Assert.AreEqual(true, DateB.HasValue);
            
            Assert.AreEqual(TempDateTime.Ticks/10000000,DateB.Value.Ticks/10000000);
        }
        private object GetValue(OracleDecimal number, OracleDate date, OracleTimeStamp timestamp, OracleTimeStampTZ timestampWithTimezone, OracleTimeStampLTZ timestampWithLocalTimeZone, OracleIntervalYM yearToMonth, OracleIntervalDS dayToSecond)
        {
            if (!LimitValuesAvailable)
            {
                return(null);
            }

            if (_valueType == typeof(OracleDecimal))
            {
                return(number.IsNull ? null : new OracleNumber(number));
            }

            if (_valueType == typeof(OracleDate))
            {
                return(date.IsNull ? null : new OracleDateTime(date));
            }

            if (_valueType == typeof(OracleTimeStamp))
            {
                return(timestamp.IsNull ? null : new OracleTimestamp(timestamp));
            }

            if (_valueType == typeof(OracleTimeStampTZ))
            {
                return(timestampWithTimezone.IsNull ? null : new OracleTimestampWithTimeZone(timestampWithTimezone));
            }

            if (_valueType == typeof(OracleTimeStampLTZ))
            {
                return(timestampWithLocalTimeZone.IsNull ? null : new OracleTimestampWithLocalTimeZone(timestampWithLocalTimeZone));
            }

            if (_valueType == typeof(OracleIntervalYM))
            {
                return(yearToMonth.IsNull ? null : new OracleIntervalYearToMonth(yearToMonth));
            }

            if (_valueType == typeof(OracleIntervalDS))
            {
                return(dayToSecond.IsNull ? null : new OracleIntervalDayToSecond(dayToSecond));
            }

            return(null);
        }
        private void button4_Click(object sender, EventArgs e)
        {
            string _connstring = "Data Source=localhost/NEWDB;User Id=EDZEHOO;Password=PASS123;";
            string _result;

            try
            {
                OracleConnection _connObj = new OracleConnection();
                _connObj.ConnectionString = _connstring;
                _connObj.Open();
                OracleGlobalization info = OracleGlobalization.GetClientInfo();
                info.DateLanguage = "FINNISH";
                info.DateFormat   = "DD-MON-YYYY";
                OracleGlobalization.SetThreadInfo(info);
                OracleCommand _cmdObj = _connObj.CreateCommand();
                _cmdObj.CommandText = "SELECT ExpiryDate FROM Products ORDER BY ExpiryDate ASC";
                OracleDataReader _reader = _cmdObj.ExecuteReader();
                _result = "Results:";
                if (_reader.HasRows)
                {
                    while (_reader.Read())
                    {
                        OracleDate _odate =
                            _reader.GetOracleDate(_reader.GetOrdinal("ExpiryDate"));
                        _result = _result + "\n" + _odate.ToString();
                    }
                }
                MessageBox.Show(_result);
                _reader.Dispose();
                _cmdObj.Dispose();
                _connObj.Dispose();
                _reader.Close();
                _connObj.Close();
                _reader  = null;
                _connObj = null;
                _cmdObj  = null;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        public void GetOracleDateArray()
        {
            var oraDateArray = new OracleDate[] {
                (OracleDate)DateTime.Now,
                (OracleDate)DateTime.Now.AddYears(1),
                new OracleDate("10/29/2020 16:14:23")
            };

            var nullableOraDateArray = new OracleDate?[] {
                (OracleDate)DateTime.Now,
                (OracleDate)DateTime.Now.AddYears(1),
                null,
                new OracleDate("10/29/2020 16:14:23")
            };
            var result = OracleValueConverter.Convert <DateTime[]>(oraDateArray);

            result.Should().BeOfType <DateTime[]>();
            result.Should().HaveCount(oraDateArray.Length);

            var secondResult = OracleValueConverter.Convert <DateTime?[]>(nullableOraDateArray);

            secondResult.Should().BeOfType <DateTime?[]>();
            secondResult.Should().HaveCount(nullableOraDateArray.Length);
        }
 /// <summary>
 /// Get an oracle parameter with a DateTime? value
 /// </summary>
 /// <param name="parametername">the name of the created parameter</param>
 /// <param name="datetime">the nullable datetime value</param>
 /// <returns>the requested oracle parameter</returns>
 public static DateTime? GetNullableDateTimeValue(OracleDate date)
 {
     if (date.IsNull)
         return null;
     else
         return date.Value;
 }
Example #13
0
        public static dynamic OracleDBTypeToNative(OracleParameter param)
        {
            switch (param.OracleDbTypeEx)
            {
            case OracleDbType.Array:
            case OracleDbType.BFile:
            case OracleDbType.BinaryDouble:
            case OracleDbType.BinaryFloat:
            case OracleDbType.Ref:
            case OracleDbType.RefCursor:
            case OracleDbType.XmlType:
                return(param.Value);

            case OracleDbType.LongRaw:
            case OracleDbType.Raw:
            case OracleDbType.Blob:
                if (param.Value == null)
                {
                    return(default(byte[]));
                }
                else
                {
                    /*TODO: this is an extremely naive implementation, and will eat RAM if large BLOBS are used.
                     *      Currently, I'm limiting at 10MB of data (defined in a const inside _Common.cs),
                     *      and raising an error if this limit is exceeded. */
                    byte[] BlobBytes;

                    OracleBlob Blob = (OracleBlob)param.Value;
                    if (Blob.Length < Max_Blob_Size)
                    {
                        BlobBytes = new byte[Blob.Length];
                        Blob.Read(BlobBytes, 0, (int)Blob.Length);
                        return(BlobBytes);
                    }
                    else
                    {
                        throw new NotSupportedException("This function will return a maximum of " + Max_Blob_Size + " bytes to avoid excessive RAM consumption.");
                    }
                }

            //this case will probably never work, so I may as well ignore it

            /*case OracleDbType.Byte:
             *  if(param.Value == null)
             *  {
             *      return default(byte);
             *  }
             *  else
             *  {
             *      return (byte)param.Value;
             *  }*/
            case OracleDbType.Char:
            case OracleDbType.NChar:
            case OracleDbType.NVarchar2:
            case OracleDbType.Varchar2:
                OracleString paramValueString = (OracleString)param.Value;
                if (paramValueString == null || paramValueString.IsNull)
                {
                    return(string.Empty);
                }
                else
                {
                    return(paramValueString.Value);
                }

            case OracleDbType.Clob:
            case OracleDbType.NClob:
                if (param.Value == null)
                {
                    return(default(string));
                }
                else
                {
                    return(((OracleClob)param.Value).Value);
                }

            case OracleDbType.Date:
                OracleDate paramValueDate = (OracleDate)param.Value;
                if (paramValueDate == null || paramValueDate.IsNull)
                {
                    return(default(DateTime));
                }
                else
                {
                    return(paramValueDate.Value);
                }

            case OracleDbType.IntervalDS:
                if (param.Value == null)
                {
                    return(default(TimeSpan));
                }
                else
                {
                    return(((OracleIntervalDS)param.Value).Value);
                }

            case OracleDbType.IntervalYM:
                if (param.Value == null)
                {
                    return(default(TimeSpan));
                }
                else
                {
                    return(((OracleIntervalYM)param.Value).Value);
                }

            case OracleDbType.TimeStamp:
                if (param.Value == null)
                {
                    return(default(DateTime));
                }
                else
                {
                    return(((OracleTimeStamp)param.Value).Value);
                }

            case OracleDbType.TimeStampLTZ:
                if (param.Value == null)
                {
                    return(default(DateTime));
                }
                else
                {
                    return(((OracleTimeStampLTZ)param.Value).Value);
                }

            case OracleDbType.TimeStampTZ:
                if (param.Value == null)
                {
                    return(default(DateTime));
                }
                else
                {
                    return(((OracleTimeStampTZ)param.Value).Value);
                }

            case OracleDbType.Int16:
            case OracleDbType.Int32:
                OracleDecimal paramValueInt32 = (OracleDecimal)param.Value;
                if (paramValueInt32 == null || paramValueInt32.IsNull)
                {
                    return(default(int));
                }
                else
                {
                    return(paramValueInt32.ToInt32());
                }

            case OracleDbType.Int64:
                OracleDecimal paramValueInt64 = (OracleDecimal)param.Value;
                if (paramValueInt64 == null || paramValueInt64.IsNull)
                {
                    return(default(Int64));
                }
                else
                {
                    return(paramValueInt64.ToInt64());
                }

            case OracleDbType.Decimal:
                OracleDecimal paramValueDecimal = (OracleDecimal)param.Value;
                if (paramValueDecimal == null || paramValueDecimal.IsNull)
                {
                    return(default(decimal));
                }
                else
                {
                    return(paramValueDecimal.Value);
                }

            case OracleDbType.Double:
            case OracleDbType.Single:     //we don't care internally about single.
                if (param.Value == null)
                {
                    return(default(double));
                }
                else
                {
                    return(((OracleDecimal)param.Value).ToDouble());
                }

            default:
                throw new NotImplementedException("Type not handled yet");
            }
        }
Example #14
0
 public static void TextWrite(this TextWriter writer, OracleDate ts1)
 {
     writer.Write($"\"{ts1.Year:D4}-{ts1.Month:D2}-{ts1.Day:D2} {ts1.Hour:D2}:{ts1.Minute:D2}:{ts1.Second:D2}\"");
 }
Example #15
0
 public OracleDateTime(OracleDate oracleDate) : this(oracleDate.Year, oracleDate.Month, oracleDate.Day, oracleDate.Hour, oracleDate.Minute, oracleDate.Second)
 {
 }
Example #16
0
        /// <summary>
        /// Insert an array of rows into Mobius warehouse table
        /// </summary>
        /// <param name="voList"></param>
        /// <returns></returns>

        public bool Insert(
            List <AnnotationVo> voList)
        {
            // This insert uses the APPEND_VALUES hint if there are 10 or more rows inserted.
            // This means that inserts will go into new blocks and be physically associated with each other
            // which will result in significantly faster retrieval for individual annotation tables since fewer
            // disk reads will be needed. Otherwise tables that are reloaded multiple times will tend to be spread over
            // a larger number of reused blocks resulting in more reads and slower performance.
            //
            // From a web article:
            //  Each of the following is a benefit in some cases
            //  Each of the following is a disaster in other cases
            //  Append does a direct path load (if it can, it is not a promise, you are requesting and we may or may not do it for you - silently)
            //  if you direct path load, the transaction that did the direct path load CANNOT query that segment -but other transactions can, they just cannot see the newly loaded data.
            //  if you direct path load, you never use any existing free space, it always writes above the high water mark.
            //  if you direct path load, we bypass UNDO on the table -only the table -modifications
            //  if you direct path load, you'll maintain indexes - we build mini indexes on the newly loaded data and merge them into the 'real' indexes in bulk. A direct path load of large amounts of data will maintain indexes very efficiently.
            //  if you direct path load you can bypass redo on the TABLE in archivelog mode, if the database is set up to allow nologging and you have the segment set to nologging
            //  direct path loading bypasses the buffer cache, you write directly to the datafiles.
            //  direct path loading is only appropriate for the first load of a segment or an increment load of lots of data - or an increment load into a table that never has any deletes(so there is no free space to consider)
            //
            //  transactional systems - you probably won't use it.
            //  warehouses - a tool you'll use a lot

            AnnotationVo vo;

            if (voList == null || voList.Count == 0)
            {
                return(false);
            }

            //CheckForDuplicateInsert(voList); // debug

            try
            {
                string sql =
                    "insert /*+ APPEND_VALUES */ into " + TableName + " " +
                    "(rslt_id, " +
                    "rslt_grp_id, " +
                    "ext_cmpnd_id_txt, " +
                    "ext_cmpnd_id_nbr, " +
                    "src_db_id, " +
                    "mthd_vrsn_id, " +
                    "rslt_typ_id, " +
                    "rslt_val_prfx_txt, " +
                    "rslt_val_nbr, " +
                    "uom_id, " +
                    "rslt_val_txt, " +
                    "rslt_val_dt, " +
                    "cmnt_txt, " +
                    "dc_lnk, " +
                    "chng_op_cd, " +
                    "chng_usr_id, " +
                    "sts_id, " +
                    "sts_dt, " +
                    "crt_dt, " +
                    "updt_dt) " +
                    "values (nvl(:0," + SeqName + ".nextval)" +              // if rslt_id not null use it otherwise call nextval locally
                    ",:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11,:12,:13,:14,:15,1,sysdate(),sysdate(),sysdate())";

                if (voList.Count < 10)                 // require minimum number of rows to use APPEND_VALUESd
                {
                    sql = Lex.Replace(sql, "APPEND_VALUES", "");
                }

                OracleDbType[] pa = new OracleDbType[16];
                pa[0]  = OracleDbType.Long;                // rslt_id
                pa[1]  = OracleDbType.Long;                // rslt_grp_id
                pa[2]  = OracleDbType.Varchar2;
                pa[3]  = OracleDbType.Int32;
                pa[4]  = OracleDbType.Int32;
                pa[5]  = OracleDbType.Int32;               // mthd_vrsn_id
                pa[6]  = OracleDbType.Long;                // rslt_typ_id
                pa[7]  = OracleDbType.Varchar2;
                pa[8]  = OracleDbType.Double;
                pa[9]  = OracleDbType.Int32;
                pa[10] = OracleDbType.Varchar2;
                pa[11] = OracleDbType.Date;
                pa[12] = OracleDbType.Varchar2;
                pa[13] = OracleDbType.Varchar2;
                pa[14] = OracleDbType.Varchar2;
                pa[15] = OracleDbType.Varchar2;

                DbCmd.Prepare(sql, pa);

                int cnt = voList.Count;

                object[]        p                  = new object[16];                   // parameter values
                object[]        rslt_idA           = new object[cnt]; p[0] = rslt_idA; // allocate arrays to hold values
                long[]          rslt_grp_idA       = new long[cnt]; p[1] = rslt_grp_idA;
                string[]        ext_cmpnd_id_txtA  = new string[cnt]; p[2] = ext_cmpnd_id_txtA;
                int[]           ext_cmpnd_id_nbrA  = new int[cnt]; p[3] = ext_cmpnd_id_nbrA;
                int[]           src_db_idA         = new int[cnt]; p[4] = src_db_idA;
                int[]           mthd_vrsn_idA      = new int[cnt]; p[5] = mthd_vrsn_idA;
                long[]          rslt_typ_idA       = new long[cnt]; p[6] = rslt_typ_idA;
                string[]        rslt_val_prfx_txtA = new string[cnt]; p[7] = rslt_val_prfx_txtA;
                OracleDecimal[] rslt_val_nbrA      = new OracleDecimal[cnt]; p[8] = rslt_val_nbrA;
                int[]           uom_idA            = new int[cnt]; p[9] = uom_idA;
                string[]        rslt_val_txtA      = new string[cnt]; p[10] = rslt_val_txtA;
                OracleDate[]    rslt_val_dtA       = new OracleDate[cnt]; p[11] = rslt_val_dtA;
                string[]        cmnt_txtA          = new string[cnt]; p[12] = cmnt_txtA;
                string[]        dc_lnkA            = new string[cnt]; p[13] = dc_lnkA;
                string[]        chng_op_cdA        = new string[cnt]; p[14] = chng_op_cdA;
                string[]        chng_usr_idA       = new string[cnt]; p[15] = chng_usr_idA;

                for (int li = 0; li < cnt; li++)
                {                 // copy values to parameter arrays
                    vo = voList[li];

                    try { vo.ext_cmpnd_id_nbr = Int32.Parse(vo.ext_cmpnd_id_txt); }                     // try to store text ext_cmpnd_id_txt value also as integer in ext_cmpnd_id_nbr
                    catch (Exception ex) { }

                    if (vo.rslt_id <= 0 && voList.Count == 1)                     // assign seq no if not already assigned if inserting only 1 row
                    {
                        vo.rslt_id = SequenceDao.NextValLong(SeqName);
                    }
                    if (vo.rslt_id > 0)
                    {
                        rslt_idA[li] = vo.rslt_id;                                     // is result_id defined?
                    }
                    else
                    {
                        rslt_idA[li] = DBNull.Value;                      // if not defined send as null value so sequence is used in nvl function in insert
                    }
                    rslt_grp_idA[li] = vo.rslt_grp_id;

                    string txt = vo.ext_cmpnd_id_txt;
                    if (txt != null && txt.Length > 32)                     // truncate to 32 chars if needed
                    {
                        txt = txt.Substring(0, 32);
                    }
                    ext_cmpnd_id_txtA[li] = txt;

                    ext_cmpnd_id_nbrA[li]  = vo.ext_cmpnd_id_nbr;
                    src_db_idA[li]         = vo.src_db_id;
                    mthd_vrsn_idA[li]      = vo.mthd_vrsn_id;
                    rslt_typ_idA[li]       = vo.rslt_typ_id;
                    rslt_val_prfx_txtA[li] = vo.rslt_val_prfx_txt;
                    if (vo.rslt_val_nbr != NullValue.NullNumber)
                    {
                        rslt_val_nbrA[li] = new OracleDecimal(vo.rslt_val_nbr);
                    }
                    uom_idA[li] = vo.uom_id;

                    rslt_val_txtA[li] = vo.rslt_val_txt;
                    if (rslt_val_txtA[li] != null && rslt_val_txtA[li].Length > 3900)                     // avoid overflow error, must leave space for catenating
                    {
                        rslt_val_txtA[li] = rslt_val_txtA[li].Substring(0, 3897) + "...";                 // link info & keeping total <= 4000
                    }
                    if (vo.rslt_val_txt.Contains(","))
                    {
                        vo.rslt_val_txt = vo.rslt_val_txt;                       // debug
                    }
                    if (vo.rslt_val_dt != DateTime.MinValue)                     // non-null date?
                    {
                        rslt_val_dtA[li] = new OracleDate(vo.rslt_val_dt);
                    }
                    cmnt_txtA[li]    = vo.cmnt_txt;
                    dc_lnkA[li]      = vo.dc_lnk;
                    chng_op_cdA[li]  = vo.chng_op_cd;
                    chng_usr_idA[li] = vo.chng_usr_id;
                }

                int t0 = TimeOfDay.Milliseconds();
                DbCmd.OracleCmd.ArrayBindCount = cnt;
                int count = DbCmd.ExecuteNonReader(p);                 // do insert

                t0 = TimeOfDay.Milliseconds() - t0;
                //				DebugLog.Message("MobiusDwDao insert rows, count = " + count.ToString() + ", Time(ms) = " + t0.ToString());

                return(true);
            }

            catch (Exception e)
            {
                DebugLog.Message("MobiusDwDao.Insert - Error inserting into " + TableName + ": " + e.Message);
                return(false);
            }
        }
Example #17
0
        /// <summary>
        /// 获取Oracle参数的值
        /// </summary>
        /// <param name="oraParam"></param>
        /// <returns></returns>
        protected virtual object GetOraParamVal(OracleParameter oraParam)
        {
            if (oraParam.Value == null || (oraParam.Value is INullable && (oraParam.Value as INullable).IsNull))
            {
                return(DBNull.Value);
            }

            object val = DBNull.Value;

            if (oraParam.Value is OracleXmlType)
            {
                OracleXmlType xmltype = (OracleXmlType)oraParam.Value;
                if (!xmltype.IsEmpty)
                {
                    val = xmltype.Value;
                }
            }
            else if (oraParam.Value is OracleBlob)
            {
                OracleBlob blobVal = (OracleBlob)oraParam.Value;
                if (!blobVal.IsNull)
                {
                    val = (oraParam.Value as OracleBlob).Value;
                }
            }
            else if (oraParam.Value is OracleClob)
            {
                OracleClob clobVal = (OracleClob)oraParam.Value;
                if (!clobVal.IsNull)
                {
                    val = clobVal.Value;
                }
            }
            else if (oraParam.Value is OracleDecimal)
            {
                OracleDecimal decimalVal = (OracleDecimal)oraParam.Value;
                if (!decimalVal.IsNull)
                {
                    val = decimalVal.Value;
                }
            }
            else if (oraParam.Value is OracleDate)
            {
                OracleDate dateVal = (OracleDate)oraParam.Value;
                if (!dateVal.IsNull)
                {
                    val = dateVal.Value;
                }
            }
            else if (oraParam.Value is OracleString)
            {
                OracleString stringVal = (OracleString)oraParam.Value;
                if (!stringVal.IsNull)
                {
                    val = stringVal.Value;
                }
            }
            else if (oraParam.Value is OracleBFile)
            {
                OracleBFile fileVal = oraParam.Value as OracleBFile;
                if (!fileVal.IsNull)
                {
                    val = fileVal.Value;
                }
            }
            else if (oraParam.Value is OracleBinary)
            {
                OracleBinary binaryVal = (OracleBinary)oraParam.Value;
                if (!binaryVal.IsNull)
                {
                    val = binaryVal.Value;
                }
            }
            else if (oraParam.Value is OracleTimeStamp)
            {
                OracleTimeStamp timeStampVal = (OracleTimeStamp)oraParam.Value;
                if (!timeStampVal.IsNull)
                {
                    val = timeStampVal.Value;
                }
            }
            else if (oraParam.Value is OracleRefCursor)
            {
                using (OracleRefCursor timeStampVal = (OracleRefCursor)oraParam.Value)
                {
                    if (timeStampVal.IsNull)
                    {
                        return(null);
                    }
                    OracleDataReader dataReader = timeStampVal.GetDataReader();
                    DataTable        datatable  = new DataTable();
                    datatable.Load(dataReader);
                    return(datatable);
                }
            }
            else
            {
                val = oraParam.Value;
            }
            return(val);
        }
Example #18
0
		private object GetValue(OracleDecimal number, OracleDate date, OracleTimeStamp timestamp, OracleTimeStampTZ timestampWithTimezone, OracleTimeStampLTZ timestampWithLocalTimeZone, OracleIntervalYM yearToMonth, OracleIntervalDS dayToSecond)
		{
			if (!LimitValuesAvailable)
			{
				return null;
			}

			if (_valueType == typeof(OracleDecimal))
			{
				return number.IsNull ? null : new OracleNumber(number);
			}

			if (_valueType == typeof(OracleDate))
			{
				return date.IsNull ? null : new OracleDateTime(date);
			}

			if (_valueType == typeof(OracleTimeStamp))
			{
				return timestamp.IsNull ? null : new OracleTimestamp(timestamp);
			}

			if (_valueType == typeof(OracleTimeStampTZ))
			{
				return timestampWithTimezone.IsNull ? null : new OracleTimestampWithTimeZone(timestampWithTimezone);
			}

			if (_valueType == typeof(OracleTimeStampLTZ))
			{
				return timestampWithLocalTimeZone.IsNull ? null : new OracleTimestampWithLocalTimeZone(timestampWithLocalTimeZone);
			}

			if (_valueType == typeof(OracleIntervalYM))
			{
				return yearToMonth.IsNull ? null : new OracleIntervalYearToMonth(yearToMonth);
			}

			if (_valueType == typeof(OracleIntervalDS))
			{
				return dayToSecond.IsNull ? null : new OracleIntervalDayToSecond(dayToSecond);
			}

			return null;
		}