Example #1
0
        public override int Add(object value)
        {
            OracleDBParameter ingPar = (OracleDBParameter)value;

            parcol.Add(ingPar.par);
            return(0);
        }
 private OracleCommand(OracleCommand command) : this()
 {
     this.CommandText       = command.CommandText;
     this.CommandType       = command.CommandType;
     this.Connection        = command.Connection;
     this.DesignTimeVisible = command.DesignTimeVisible;
     this.UpdatedRowSource  = command.UpdatedRowSource;
     this.Transaction       = command.Transaction;
     if ((command._parameterCollection != null) && (0 < command._parameterCollection.Count))
     {
         OracleParameterCollection parameters = this.Parameters;
         foreach (ICloneable cloneable in command.Parameters)
         {
             parameters.Add(cloneable.Clone());
         }
     }
 }
        public static void DeriveParameters(OracleCommand command)
        {
            OracleConnection.ExecutePermission.Demand();
            if (command == null)
            {
                throw System.Data.Common.ADP.ArgumentNull("command");
            }
            CommandType commandType = command.CommandType;

            if (commandType != CommandType.Text)
            {
                if (commandType == CommandType.StoredProcedure)
                {
                    if (System.Data.Common.ADP.IsEmpty(command.CommandText))
                    {
                        throw System.Data.Common.ADP.CommandTextRequired("DeriveParameters");
                    }
                    OracleConnection connection = command.Connection;
                    if (connection == null)
                    {
                        throw System.Data.Common.ADP.ConnectionRequired("DeriveParameters");
                    }
                    ConnectionState state = connection.State;
                    if (ConnectionState.Open != state)
                    {
                        throw System.Data.Common.ADP.OpenConnectionRequired("DeriveParameters", state);
                    }
                    ArrayList list = DeriveParametersFromStoredProcedure(connection, command);
                    OracleParameterCollection parameters = command.Parameters;
                    parameters.Clear();
                    int count = list.Count;
                    for (int i = 0; i < count; i++)
                    {
                        parameters.Add((OracleParameter)list[i]);
                    }
                    return;
                }
                if (commandType != CommandType.TableDirect)
                {
                    throw System.Data.Common.ADP.InvalidCommandType(command.CommandType);
                }
            }
            throw System.Data.Common.ADP.DeriveParametersNotSupported(command);
        }
		/// <summary>
		/// Builds an OracleParametersCollection for an INSERT command, according to the DbTypeParameters in this collection.
		/// </summary>
		/// <param name="a_oParams">The OracleParameterCollection to be filled.</param>
		private void AddInsertCommandParameters(OracleParameterCollection a_oParams)
		{
			foreach (DbTypeParameter l_oCurrent in this)
			{
				a_oParams.Add(l_oCurrent.ParameterName, l_oCurrent.Value);
			}
		}
Example #5
0
 public static OracleParameter AddReturnString(OracleParameterCollection parameters, String name, OracleType type, Int32 size)
 {
     OracleParameter parameter = new OracleParameter();
     parameter.Direction = ParameterDirection.ReturnValue;
     parameter.ParameterName = name;
     parameter.OracleType = type;
     parameter.Size = size;
     parameters.Add(parameter);
     return parameter;
 }
Example #6
0
 public static OracleParameter AddOutput(OracleParameterCollection parameters, String name, OracleType type)
 {
     OracleParameter parameter = new OracleParameter();
     parameter.Direction = ParameterDirection.Output;
     parameter.ParameterName = name;
     parameter.OracleType = type;
     parameters.Add(parameter);
     return parameter;
 }
Example #7
0
 public static OracleParameter AddInput(OracleParameterCollection parameters, String name, OracleType type, Object val)
 {
     OracleParameter parameter = new OracleParameter();
     parameter.Direction = ParameterDirection.Input;
     parameter.ParameterName = name;
     parameter.Value = val;
     parameter.OracleType = type;
     parameters.Add(parameter);
     return parameter;
 }
        private DataSet GetCodApparecchiature(string CodEdificio, string CodServizio, string Apparecchiatura)
        {
            System.Data.OracleClient.OracleParameterCollection Coll = new System.Data.OracleClient.OracleParameterCollection();

            System.Data.OracleClient.OracleParameter p_Bl_Id = new System.Data.OracleClient.OracleParameter();
            p_Bl_Id.ParameterName = "p_Bl_Id";
            p_Bl_Id.Size          = 50;
            p_Bl_Id.Direction     = ParameterDirection.Input;
            p_Bl_Id.OracleType    = OracleType.VarChar;
            p_Bl_Id.Value         = "";
            Coll.Add(p_Bl_Id);

            OracleParameter s_p_campus = new OracleParameter();

            s_p_campus.ParameterName = "p_campus";
            s_p_campus.Direction     = ParameterDirection.Input;
            s_p_campus.OracleType    = OracleType.VarChar;
            s_p_campus.Value         = CodEdificio;
            Coll.Add(s_p_campus);

            OracleParameter s_p_Servizio = new OracleParameter();

            s_p_Servizio.ParameterName = "p_Servizio";
            s_p_Servizio.Direction     = ParameterDirection.Input;
            s_p_Servizio.OracleType    = OracleType.Int32;
            s_p_Servizio.Value         = (CodServizio == "")? 0:Int32.Parse(CodServizio);
            Coll.Add(s_p_Servizio);


            OracleParameter s_p_eqstdid = new OracleParameter();

            s_p_eqstdid.ParameterName = "p_eqstdid";
            s_p_eqstdid.Direction     = ParameterDirection.Input;
            s_p_eqstdid.OracleType    = OracleType.Int32;
            s_p_eqstdid.Value         = (Apparecchiatura == "")? 0:Int32.Parse(Apparecchiatura);
            s_p_eqstdid.Size          = 8;
            Coll.Add(s_p_eqstdid);


            OracleParameter s_p_eq_id = new OracleParameter();

            s_p_eq_id.ParameterName = "p_eq_id";
            s_p_eq_id.Direction     = ParameterDirection.Input;
            s_p_eq_id.OracleType    = OracleType.VarChar;
            s_p_eq_id.Value         = "";   //(cmbEQ.SelectedValue==string.Empty)? "":cmbEQ.Items[cmbEQ.SelectedIndex].Text;
            s_p_eq_id.Size          = 50;
            Coll.Add(s_p_eq_id);

            // 19-07-2005 Armando: aggiunto parametro
            OracleParameter p_dismesso = new OracleParameter();

            p_dismesso.ParameterName = "p_dismesso";
            p_dismesso.Direction     = ParameterDirection.Input;
            p_dismesso.OracleType    = OracleType.Int32;
            p_dismesso.Value         = 0;
            Coll.Add(p_dismesso);
            // Armando fine

            OracleParameter p_Username = new OracleParameter();

            p_Username.ParameterName = "p_Username";
            p_Username.Size          = 50;
            p_Username.Direction     = ParameterDirection.Input;
            p_Username.OracleType    = OracleType.VarChar;
            p_Username.Value         = this.userName;
            Coll.Add(p_Username);


            OracleParameter PaCursor = new OracleParameter();

            PaCursor.ParameterName = "IO_CURSOR";
            PaCursor.Direction     = ParameterDirection.Output;
            PaCursor.OracleType    = OracleType.Cursor;
            Coll.Add(PaCursor);


            DataSet _MyDs = base.GetData(Coll, "PACK_APPARECCHIATURE.SP_RICERCAAPPARECCHIATURA");

            return(_MyDs);
        }
		[Test] // Add (Object)
		public void Add1_Value_Owned ()
		{
			OracleParameter param = new OracleParameter ("ParamI", 1);

			o.Add ((object) param);

			// attempt to add same OracleParameter to collection twice
			try {
				o.Add ((object) param);
				Assert.Fail ("#A1");
			} catch (ArgumentException ex) {
				// The OracleParameter is already contained by
				// another OracleParameterCollection
				Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
				Assert.IsNull (ex.InnerException, "#A3");
				Assert.IsNotNull (ex.Message, "#A4");
				Assert.IsTrue (ex.Message.IndexOf (o.GetType ().Name) != -1, "#A5");
				Assert.IsTrue (ex.Message.IndexOf (typeof (OracleParameter).Name) != -1, "#A6");
				Assert.IsNull (ex.ParamName, "#A7");
			}

			OracleParameterCollection o2 = new OracleParameterCollection ();

			// attempt to add OracleParameter to another collection
			try {
				o2.Add ((object) param);
				Assert.Fail ("#B1");
			} catch (ArgumentException ex) {
				// The OracleParameter is already contained by
				// another OracleParameterCollection
				Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
				Assert.IsNull (ex.InnerException, "#B3");
				Assert.IsNotNull (ex.Message, "#B4");
				Assert.IsTrue (ex.Message.IndexOf (o.GetType ().Name) != -1, "#B5");
				Assert.IsTrue (ex.Message.IndexOf (typeof (OracleParameter).Name) != -1, "#B6");
				Assert.IsNull (ex.ParamName, "#B7");
			}

			o.Remove ((object) param);
			o.Add ((object) param);
			o.Remove ((object) param);
			o2.Add ((object) param);
		}
		[Test] // OracleParameter this [String]
		public void Indexer2 ()
		{
			OracleParameter paramA = new OracleParameter ("ParamI", 1);
			OracleParameter paramB = new OracleParameter ("Parami", 2);
			OracleParameter paramC = new OracleParameter ("paramI", 3);
			OracleParameter paramD = new OracleParameter ("parami", 4);
			OracleParameter paramE = new OracleParameter ("ParamI", 5);
			OracleParameter paramF = new OracleParameter ("Parami", 6);
			OracleParameter paramG = new OracleParameter ("ParamG", 7);
			OracleParameter paramH = new OracleParameter ("ParamH", 8);

			o.Add (paramA);
			o.Add (paramB);
			o.Add (paramC);
			o.Add (paramD);
			o.Add (paramE);
			o.Add (paramF);

			Assert.AreSame (paramA, o ["ParamI"], "#A1");
			Assert.AreSame (paramB, o ["Parami"], "#A2");
			Assert.AreSame (paramC, o ["paramI"], "#A3");
			Assert.AreSame (paramD, o ["parami"], "#A4");
			Assert.AreEqual (0, o.IndexOf (paramA), "#A5");
			Assert.AreEqual (1, o.IndexOf (paramB), "#A6");
			Assert.AreEqual (2, o.IndexOf (paramC), "#A7");
			Assert.AreEqual (3, o.IndexOf (paramD), "#A8");
			Assert.AreEqual (4, o.IndexOf (paramE), "#A9");
			Assert.AreEqual (5, o.IndexOf (paramF), "#A10");
			Assert.AreEqual (-1, o.IndexOf (paramG), "#A11");
			Assert.AreEqual (-1, o.IndexOf (paramH), "#A12");

			o ["ParamI"] = paramG;
			Assert.AreSame (paramE, o ["ParamI"], "#B1");
			Assert.AreSame (paramB, o ["Parami"], "#B2");
			Assert.AreSame (paramC, o ["paramI"], "#B3");
			Assert.AreSame (paramD, o ["parami"], "#B4");
			Assert.AreSame (paramG, o ["paramG"], "#B5");
			Assert.AreEqual (-1, o.IndexOf (paramA), "#B6");
			Assert.AreEqual (1, o.IndexOf (paramB), "#B7");
			Assert.AreEqual (2, o.IndexOf (paramC), "#B8");
			Assert.AreEqual (3, o.IndexOf (paramD), "#B9");
			Assert.AreEqual (4, o.IndexOf (paramE), "#B10");
			Assert.AreEqual (5, o.IndexOf (paramF), "#B11");
			Assert.AreEqual (0, o.IndexOf (paramG), "#B12");
			Assert.AreEqual (-1, o.IndexOf (paramH), "#B13");

			o ["ParamI"] = paramH;
			Assert.AreSame (paramC, o ["ParamI"], "#C1");
			Assert.AreSame (paramB, o ["Parami"], "#C2");
			Assert.AreSame (paramC, o ["paramI"], "#C3");
			Assert.AreSame (paramD, o ["parami"], "#C4");
			Assert.AreSame (paramG, o ["paramG"], "#C5");
			Assert.AreSame (paramH, o ["paramH"], "#C6");
			Assert.AreEqual (-1, o.IndexOf (paramA), "#C6");
			Assert.AreEqual (1, o.IndexOf (paramB), "#C7");
			Assert.AreEqual (2, o.IndexOf (paramC), "#C8");
			Assert.AreEqual (3, o.IndexOf (paramD), "#C9");
			Assert.AreEqual (-1, o.IndexOf (paramE), "#C10");
			Assert.AreEqual (5, o.IndexOf (paramF), "#C11");
			Assert.AreEqual (0, o.IndexOf (paramG), "#C12");
			Assert.AreEqual (4, o.IndexOf (paramH), "#C13");

			o ["paramG"] = paramA;
			Assert.AreSame (paramA, o ["ParamI"], "#D1");
			Assert.AreSame (paramB, o ["Parami"], "#D2");
			Assert.AreSame (paramC, o ["paramI"], "#D3");
			Assert.AreSame (paramD, o ["parami"], "#D4");
			Assert.AreSame (paramH, o ["paramH"], "#D5");
			Assert.AreEqual (0, o.IndexOf (paramA), "#D6");
			Assert.AreEqual (1, o.IndexOf (paramB), "#D7");
			Assert.AreEqual (2, o.IndexOf (paramC), "#D8");
			Assert.AreEqual (3, o.IndexOf (paramD), "#D9");
			Assert.AreEqual (-1, o.IndexOf (paramE), "#D10");
			Assert.AreEqual (5, o.IndexOf (paramF), "#D11");
			Assert.AreEqual (-1, o.IndexOf (paramG), "#D12");
			Assert.AreEqual (4, o.IndexOf (paramH), "#D13");

			o ["ParamI"] = paramA;
			Assert.AreSame (paramA, o ["ParamI"], "#E1");
			Assert.AreSame (paramB, o ["Parami"], "#E2");
			Assert.AreSame (paramC, o ["paramI"], "#E3");
			Assert.AreSame (paramD, o ["parami"], "#E4");
			Assert.AreSame (paramH, o ["paramH"], "#E5");
			Assert.AreEqual (0, o.IndexOf (paramA), "#E6");
			Assert.AreEqual (1, o.IndexOf (paramB), "#E7");
			Assert.AreEqual (2, o.IndexOf (paramC), "#E8");
			Assert.AreEqual (3, o.IndexOf (paramD), "#E9");
			Assert.AreEqual (-1, o.IndexOf (paramE), "#E10");
			Assert.AreEqual (5, o.IndexOf (paramF), "#E11");
			Assert.AreEqual (-1, o.IndexOf (paramG), "#E12");
			Assert.AreEqual (4, o.IndexOf (paramH), "#E13");

			o ["paramI"] = paramC;
			Assert.AreSame (paramA, o ["ParamI"], "#F1");
			Assert.AreSame (paramB, o ["Parami"], "#F2");
			Assert.AreSame (paramC, o ["paramI"], "#F3");
			Assert.AreSame (paramD, o ["parami"], "#F4");
			Assert.AreSame (paramH, o ["paramH"], "#F5");
			Assert.AreEqual (0, o.IndexOf (paramA), "#F6");
			Assert.AreEqual (1, o.IndexOf (paramB), "#F7");
			Assert.AreEqual (2, o.IndexOf (paramC), "#F8");
			Assert.AreEqual (3, o.IndexOf (paramD), "#F9");
			Assert.AreEqual (-1, o.IndexOf (paramE), "#F10");
			Assert.AreEqual (5, o.IndexOf (paramF), "#F11");
			Assert.AreEqual (-1, o.IndexOf (paramG), "#F12");
			Assert.AreEqual (4, o.IndexOf (paramH), "#F13");

			OracleParameterCollection o2 = new OracleParameterCollection ();
			o2.Add (paramE);
		}
		[Test] // OracleParameter this [Int32]
		public void Indexer1 ()
		{
			OracleParameter paramA = new OracleParameter ("ParamI", 1);
			OracleParameter paramB = new OracleParameter ("paramI", 2);
			OracleParameter paramC = new OracleParameter ("Parami", 3);

			o.Add (paramA);
			o.Add (paramB);

			Assert.AreSame (paramA, o [0], "#A1");
			Assert.AreSame (paramB, o [1], "#A2");
			o [0] = paramA;
			Assert.AreSame (paramA, o [0], "#B1");
			Assert.AreSame (paramB, o [1], "#B2");
			o [0] = paramC;
			Assert.AreSame (paramC, o [0], "#C1");
			Assert.AreSame (paramB, o [1], "#C2");
			o [1] = paramA;
			Assert.AreSame (paramC, o [0], "#D1");
			Assert.AreSame (paramA, o [1], "#D2");

			OracleParameterCollection o2 = new OracleParameterCollection ();
			o2.Add (paramB);
		}
		[Test] // RemoveAt (String)
		public void RemoveAt2 ()
		{
			OracleParameter paramA = new OracleParameter ("ParamI", 1);
			OracleParameter paramB = new OracleParameter ("Parami", 2);
			OracleParameter paramC = new OracleParameter ("paramI", 3);
			OracleParameter paramD = new OracleParameter ("parami", 4);
			OracleParameter paramE = new OracleParameter ("parami", 5);

			o.Add (paramA);
			o.Add (paramB);
			o.Add (paramC);
			o.Add (paramD);
			o.Add (paramE);

			o.RemoveAt ("paramI");

			Assert.AreEqual (0, o.IndexOf (paramA), "#A1");
			Assert.AreEqual (1, o.IndexOf (paramB), "#A2");
			Assert.AreEqual (-1, o.IndexOf (paramC), "#A3");
			Assert.AreEqual (2, o.IndexOf (paramD), "#A4");
			Assert.AreEqual (3, o.IndexOf (paramE), "#A5");

			o.RemoveAt ("parami");

			Assert.AreEqual (0, o.IndexOf (paramA), "#B1");
			Assert.AreEqual (1, o.IndexOf (paramB), "#B2");
			Assert.AreEqual (-1, o.IndexOf (paramC), "#B3");
			Assert.AreEqual (-1, o.IndexOf (paramD), "#B4");
			Assert.AreEqual (2, o.IndexOf (paramE), "#B5");

			o.RemoveAt ("Parami");

			Assert.AreEqual (0, o.IndexOf (paramA), "#C1");
			Assert.AreEqual (-1, o.IndexOf (paramB), "#C2");
			Assert.AreEqual (-1, o.IndexOf (paramC), "#C3");
			Assert.AreEqual (-1, o.IndexOf (paramD), "#C4");
			Assert.AreEqual (1, o.IndexOf (paramE), "#C5");

			o.RemoveAt ("Parami");

			Assert.AreEqual (0, o.IndexOf (paramA), "#D1");
			Assert.AreEqual (-1, o.IndexOf (paramB), "#D2");
			Assert.AreEqual (-1, o.IndexOf (paramC), "#D3");
			Assert.AreEqual (-1, o.IndexOf (paramD), "#D4");
			Assert.AreEqual (-1, o.IndexOf (paramE), "#D5");

			o.RemoveAt ("ParamI");

			Assert.AreEqual (-1, o.IndexOf (paramA), "#E1");
			Assert.AreEqual (-1, o.IndexOf (paramB), "#E2");
			Assert.AreEqual (-1, o.IndexOf (paramC), "#E3");
			Assert.AreEqual (-1, o.IndexOf (paramD), "#E4");
			Assert.AreEqual (-1, o.IndexOf (paramE), "#E5");

			o.Add (paramA);
			o.Add (paramB);
			o.Add (paramE);

			OracleParameterCollection o2 = new OracleParameterCollection ();
			o2.Add (paramC);
			o2.Add (paramD);
		}
		[Test] // RemoveAt (Int32)
		public void RemoveAt1 ()
		{
			OracleParameter paramA = new OracleParameter ("ParamI", 1);
			OracleParameter paramB = new OracleParameter ("Parami", 2);
			OracleParameter paramC = new OracleParameter ("paramI", 3);

			o.Add (paramA);
			o.Add (paramB);
			o.Add (paramC);

			o.RemoveAt (2);

			Assert.AreEqual (0, o.IndexOf (paramA), "#A1");
			Assert.AreEqual (1, o.IndexOf (paramB), "#A2");
			Assert.AreEqual (-1, o.IndexOf (paramC), "#A3");

			o.RemoveAt (0);

			Assert.AreEqual (-1, o.IndexOf (paramA), "#B1");
			Assert.AreEqual (0, o.IndexOf (paramB), "#B2");
			Assert.AreEqual (-1, o.IndexOf (paramC), "#B3");

			o.RemoveAt (0);

			Assert.AreEqual (-1, o.IndexOf (paramA), "#C1");
			Assert.AreEqual (-1, o.IndexOf (paramB), "#C2");
			Assert.AreEqual (-1, o.IndexOf (paramC), "#C3");

			o.Add (paramA);
			o.Add (paramC);

			OracleParameterCollection o2 = new OracleParameterCollection ();
			o2.Add (paramB);
		}
Example #14
0
 public static void AddParameter(string name, object value, OracleType oracleType, OracleParameterCollection parameters)
 {
     OracleParameter p = new OracleParameter("p" + name, oracleType);
     switch (oracleType)
     {
         case OracleType.NVarChar:
         case OracleType.VarChar:
         case OracleType.Clob:
         case OracleType.NClob:
             if (value == null)
             {
                 p.Value = string.Empty;
             }
             else
             {
                 if (value.ToString() == "")
                 {
                     p.Value = string.Empty;
                 }
                 else
                 {
                     p.Value = value;
                 }
             }
             
             break;
         case OracleType.DateTime:
             p.Value = value == null ? DateTime.Now : value;
             break;
         default:
             throw new Exception("AddParameter:oracleType未定义");
             
     }
     parameters.Add(p);
     
 }