Esempio n. 1
0
        public override ICollection <ParameterSchema> GetProcedureParameters(ProcedureSchema procedure)
        {
            CheckConnectionState();
            List <ParameterSchema> parameters = new List <ParameterSchema> ();

            IDbCommand command = connectionProvider.CreateCommand(
                "SELECT RDB$PARAMETER_NAME, RDB$PARAMETER_NUMBER, RDB$DESCRIPTION, RDB$SYSTEM_FLAG "
                + "FROM RDB$PROCEDURE_PARAMETERS "
                + "WHERE RDB$PROCEDURE_NAME = '" + procedure.Name + "' "
                + "AND RDB$PARAMETER_TYPE = 0 "
                + "ORDER BY 2;"
                );

            using (command) {
                using (IDataReader r = command.ExecuteReader()) {
                    while (r.Read())
                    {
                        ParameterSchema parameter = new ParameterSchema(this);

                        parameter.Name      = r.GetString(0);
                        parameter.OwnerName = procedure.Name;
                        parameter.Comment   = r.GetString(2);
                        //TODO: data type

                        parameters.Add(parameter);
                    }
                    r.Close();
                }
                connectionProvider.Close(command.Connection);
            }

            return(parameters);
        }
Esempio n. 2
0
		public ParameterSchema (ParameterSchema param)
			: base (param)
		{
			this.dataType = param.dataType;
			this.paramType = param.paramType;
			this.position = param.position;
		}
        public virtual ParameterSchema GetNewParameterSchema(string name)
        {
            ParameterSchema schema = new ParameterSchema(this);

            schema.Name = name;
            return(schema);
        }
 public ParameterSchema(ParameterSchema param)
     : base(param)
 {
     this.dataType  = param.dataType;
     this.paramType = param.paramType;
     this.position  = param.position;
 }
        protected virtual ParameterSchema GetProcedureParameter(DataRow row, ProcedureSchema procedure)
        {
            ParameterSchema schema = new ParameterSchema(this);

            schema.SchemaName   = procedure.SchemaName;
            schema.Name         = GetRowString(row, procedureParameterItemStrings[0]);
            schema.DataTypeName = GetRowString(row, procedureParameterItemStrings[1]);
            schema.Position     = GetRowInt(row, procedureParameterItemStrings[2]);

            string paramType = GetRowString(row, procedureParameterItemStrings[3]);

            schema.ParameterType = String.Compare(paramType, "IN", true) == 0 ?
                                   ParameterType.In : (String.Compare(paramType, "OUT", true) == 0 ?
                                                       ParameterType.Out : ParameterType.InOut);

            return(schema);
        }
        public override ParameterSchemaCollection GetProcedureParameters(ProcedureSchema procedure)
        {
            ParameterSchemaCollection parameters = new ParameterSchemaCollection();

            // FIXME: Won't work properly with overload functions.
            // Maybe check the number of columns in the parameters for
            // proper match.
            IPooledDbConnection conn    = connectionPool.Request();
            IDbCommand          command = conn.CreateCommand(String.Format(
                                                                 "SELECT format_type (prorettype, NULL) "
                                                                 + "FROM pg_proc pc, pg_language pl "
                                                                 + "WHERE pc.prolang = pl.oid "
                                                                 + "AND pc.proname = '{0}';", procedure.Name
                                                                 ));

            try {
                using (command) {
                    using (IDataReader r = command.ExecuteReader()) {
                        while (r.Read())
                        {
                            ParameterSchema param = new ParameterSchema(this);

                            param.DataTypeName = r.GetString(0);
                            param.Name         = r.GetString(0);
                            parameters.Add(param);
                        }
                        r.Close();
                    }
                }
            } catch (Exception e) {
                QueryService.RaiseException(e);
            }
            conn.Release();

            return(parameters);
        }
		public override ICollection<ParameterSchema> GetProcedureParameters (ProcedureSchema procedure)
		{
			CheckConnectionState ();
			List<ParameterSchema> parameters = new List<ParameterSchema> ();
			
			IDbCommand command = connectionProvider.CreateCommand (
				"SELECT RDB$PARAMETER_NAME, RDB$PARAMETER_NUMBER, RDB$DESCRIPTION, RDB$SYSTEM_FLAG "
				+ "FROM RDB$PROCEDURE_PARAMETERS "
				+ "WHERE RDB$PROCEDURE_NAME = '" + procedure.Name + "' "
				+ "AND RDB$PARAMETER_TYPE = 0 "
				+ "ORDER BY 2;"
			);
			
			using (command) {
			    	using (IDataReader r = command.ExecuteReader()) {
			    		while (r.Read ()) {
						ParameterSchema parameter = new ParameterSchema (this);
			    			
						parameter.Name = r.GetString (0);
			    			parameter.OwnerName = procedure.Name;
						parameter.Comment = r.GetString (2);
						//TODO: data type
			    				
			    			parameters.Add (parameter);
			    		}
					r.Close ();
				}
				connectionProvider.Close (command.Connection);
			}
			
			return parameters;
		public ParameterContainer (ParameterSchema parameter)
		{
			if (parameter == null)
				throw new ArgumentNullException ("parameter");
			this.parameter = parameter;
		}
		public virtual ParameterSchema GetNewParameterSchema (string name)
		{
			ParameterSchema schema = new ParameterSchema (this);
			schema.Name = name;
			return schema;
		}
		protected virtual ParameterSchema GetProcedureParameter (DataRow row, ProcedureSchema procedure)
		{
			ParameterSchema schema = new ParameterSchema (this);
			
			schema.SchemaName = procedure.SchemaName;
			schema.Name = GetRowString (row, procedureParameterItemStrings[0]);
			schema.DataTypeName = GetRowString (row, procedureParameterItemStrings[1]);
			schema.Position = GetRowInt (row, procedureParameterItemStrings[2]);
			
			string paramType = GetRowString (row, procedureParameterItemStrings[3]);
			schema.ParameterType = String.Compare (paramType, "IN", true) == 0 ?
				ParameterType.In : (String.Compare (paramType, "OUT", true) == 0 ?
				ParameterType.Out : ParameterType.InOut);
			
			return schema;
		}
        public override ParameterSchemaCollection GetProcedureParameters(ProcedureSchema procedure)
        {
            ParameterSchemaCollection parameters = new ParameterSchemaCollection();

            IPooledDbConnection conn    = connectionPool.Request();
            IDbCommand          command = conn.CreateCommand(
                "SELECT param_list FROM mysql.proc where name = '" + procedure.Name + "'"
                );

            try {
                using (command) {
                    if (GetMainVersion(command) >= 5)
                    {
                        using (IDataReader r = command.ExecuteReader()) {
                            while (r.Read())
                            {
                                if (r.IsDBNull(0))
                                {
                                    continue;
                                }

                                string[] field = Encoding.ASCII.GetString((byte[])r.GetValue(0)).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                                foreach (string chunk in field)
                                {
                                    ParameterSchema param = new ParameterSchema(this);
                                    param.Definition = chunk;

                                    string[] tmp       = chunk.TrimStart(new char[] { ' ' }).Split(new char[] { ' ' });
                                    int      nameIndex = 0;
                                    if (String.Compare(tmp[0], "OUT", true) == 0)
                                    {
                                        nameIndex           = 1;
                                        param.ParameterType = ParameterType.Out;
                                    }
                                    else if (String.Compare(tmp[0], "INOUT", true) == 0)
                                    {
                                        nameIndex           = 1;
                                        param.ParameterType = ParameterType.InOut;
                                    }
                                    else
                                    {
                                        param.ParameterType = ParameterType.In;
                                    }

                                    param.Name         = tmp[nameIndex];
                                    param.OwnerName    = procedure.Name;
                                    param.DataTypeName = tmp[nameIndex + 1];

                                    parameters.Add(param);
                                }
                            }
                            r.Close();
                        }
                    }                     //else: do nothing, since procedures are only supported since mysql 5.x
                }
            } catch (Exception e) {
                QueryService.RaiseException(e);
            }
            conn.Release();

            return(parameters);
        }
		
		public override ParameterSchemaCollection GetProcedureParameters (ProcedureSchema procedure)
		{
			ParameterSchemaCollection parameters = new ParameterSchemaCollection ();
			
			// FIXME: Won't work properly with overload functions.
			// Maybe check the number of columns in the parameters for
			// proper match.
			IPooledDbConnection conn = connectionPool.Request ();
			IDbCommand command = conn.CreateCommand (String.Format (
				"SELECT format_type (prorettype, NULL) "
				+ "FROM pg_proc pc, pg_language pl "
				+ "WHERE pc.prolang = pl.oid "
				+ "AND pc.proname = '{0}';", procedure.Name
			));
			try {
			using (command) {
			    	using (IDataReader r = command.ExecuteReader()) {
			    		while (r.Read ()) {	
						ParameterSchema param = new ParameterSchema (this);

						param.DataTypeName = r.GetString (0);
						param.Name = r.GetString (0);
						parameters.Add (param);
			    		}
					r.Close ();
				}
			}
			} catch (Exception e) {
				QueryService.RaiseException (e);
			}
			conn.Release ();
			
			return parameters;