コード例 #1
0
		public ViewSchema (ViewSchema view)
			: base (view)
		{
			this.isSystemView = view.isSystemView;
			this.statement = view.statement;
			this.columns = new ColumnSchemaCollection (view.columns);
		}
コード例 #2
0
        public virtual ViewSchema CreateViewSchema(string name)
        {
            ViewSchema schema = new ViewSchema(this);

            schema.Name = name;
            return(schema);
        }
コード例 #3
0
		public ViewSchemaContainer (ViewSchema schema)
		{
			if (schema == null)
				throw new ArgumentNullException ("schema");
			
			this.schema = schema;
		}
コード例 #4
0
        public override ICollection <ColumnSchema> GetViewColumns(ViewSchema view)
        {
            CheckConnectionState();
            List <ColumnSchema> columns = new List <ColumnSchema> ();

            //TODO:
            return(columns);
        }
コード例 #5
0
        //http://www.sqlite.org/lang_createview.html
        public override void CreateView(ViewSchema view)
        {
            IPooledDbConnection conn    = connectionPool.Request();
            IDbCommand          command = conn.CreateCommand(view.Definition);

            using (command)
                conn.ExecuteNonQuery(command);
            conn.Release();
        }
コード例 #6
0
        protected virtual ColumnSchema GetViewColumn(DataRow row, ViewSchema view)
        {
            ColumnSchema schema = new ColumnSchema(this, view);

            schema.SchemaName = view.SchemaName;
            schema.Name       = GetRowString(row, viewColumnItemStrings[0]);

            return(schema);
        }
コード例 #7
0
        protected virtual ViewSchema GetView(DataRow row)
        {
            ViewSchema schema = new ViewSchema(this);

            schema.SchemaName = GetRowString(row, viewItemStrings[0]);
            schema.Name       = GetRowString(row, viewItemStrings[1]);
            schema.Comment    = GetRowString(row, viewItemStrings[2]);

            return(schema);
        }
コード例 #8
0
		public void Initialize (ViewSchema view)
		{
			if (view == null)
				throw new ArgumentNullException ("view");
			this.view = view;
			
			if (action == SchemaActions.Alter) {
//				sqlEditor.Text = schemaProvider.GetViewAlterStatement (view);
				commentEditor.Comment = view.Comment;
			}
		}
コード例 #9
0
        public override object Clone()
        {
            ViewSchema clone = new ViewSchema(this);

            if (clone.columns != null)
            {
                foreach (ColumnSchema column in clone.columns)
                {
                    column.Parent = clone;
                }
            }
            return(clone);
        }
コード例 #10
0
        public override ViewSchemaCollection GetViews()
        {
            ViewSchemaCollection views = new ViewSchemaCollection();

            IPooledDbConnection conn    = connectionPool.Request();
            IDbCommand          command = conn.CreateCommand(
                "SELECT v.schemaname, v.viewname, v.viewowner, v.definition,"
                + " (c.oid <= " + LastSystemOID + "), "
                + "(SELECT description from pg_description pd, "
                + " pg_class pc WHERE pc.oid=pd.objoid AND pc.relname="
                + " v.viewname) "
                + "FROM pg_views v, pg_class c "
                + "WHERE v.viewname = c.relname "
                + "ORDER BY viewname"
                );

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

                            view.Name         = r.GetString(1);
                            view.OwnerName    = r.GetString(2);
                            view.SchemaName   = r.GetString(0);
                            view.IsSystemView = r.GetBoolean(4);
                            view.Comment      = r.IsDBNull(5) ? null : r.GetString(5);

//							StringBuilder sb = new StringBuilder();
//							sb.AppendFormat ("-- View: {0}\n", view.Name);
//							sb.AppendFormat ("-- DROP VIEW {0};\n\n", view.Name);
//							sb.AppendFormat ("CREATE VIEW {0} AS (\n", view.Name);
//							string core = r.GetString(3);
//							sb.AppendFormat ("  {0}\n);", core.Substring (0, core.Length-1));
//							view.Definition = sb.ToString ();

                            views.Add(view);
                        }
                        r.Close();
                    }
                }
            } catch (Exception e) {
                QueryService.RaiseException(e);
            }
            conn.Release();

            return(views);
        }
コード例 #11
0
        public override ColumnSchemaCollection GetViewColumns(ViewSchema view)
        {
            ColumnSchemaCollection columns = new ColumnSchemaCollection();

            IPooledDbConnection conn    = connectionPool.Request();
            IDbCommand          command = conn.CreateCommand(
                "SELECT attname, typname, attlen, attnotnull "
                + "FROM "
                + "  pg_catalog.pg_attribute a LEFT JOIN pg_catalog.pg_attrdef adef "
                + "  ON a.attrelid=adef.adrelid "
                + "  AND a.attnum=adef.adnum "
                + "  LEFT JOIN pg_catalog.pg_type t ON a.atttypid=t.oid "
                + "WHERE "
                + "  a.attrelid = (SELECT oid FROM pg_catalog.pg_class WHERE relname='"
                + view.Name + "') "
                + "  AND a.attnum > 0 AND NOT a.attisdropped "
                + "     ORDER BY a.attnum;"
                );

            try {
                using (command) {
                    using (IDataReader r = command.ExecuteReader()) {
                        while (r.Read())
                        {
                            ColumnSchema column = new ColumnSchema(this, view);

                            column.Name         = r.GetString(0);
                            column.DataTypeName = r.GetString(1);
                            column.SchemaName   = view.SchemaName;
                            column.IsNullable   = r.GetBoolean(3);
                            column.DataType.LengthRange.Default = r.GetInt32(2);

                            columns.Add(column);
                        }
                        r.Close();
                    };
                }
            } catch (Exception e) {
                QueryService.RaiseException(e);
            }
            conn.Release();

            return(columns);
        }
コード例 #12
0
        // see: http://dev.mysql.com/doc/refman/5.1/en/views-table.html
        public override ViewSchemaCollection GetViews()
        {
            ViewSchemaCollection views = new ViewSchemaCollection();

            IPooledDbConnection conn    = connectionPool.Request();
            IDbCommand          command = conn.CreateCommand(
                "SELECT TABLE_NAME, TABLE_SCHEMA FROM information_schema.VIEWS where TABLE_SCHEMA = '"
                + ConnectionPool.ConnectionContext.ConnectionSettings.Database +
                "' ORDER BY TABLE_NAME"
                );

            try {
                using (command) {
                    if (GetMainVersion(command) >= 5)
                    {
                        using (IDataReader r = command.ExecuteReader()) {
                            while (r.Read())
                            {
                                ViewSchema view = new ViewSchema(this);

                                view.Name      = r.GetString(0);
                                view.OwnerName = r.GetString(1);

                                IPooledDbConnection conn2    = connectionPool.Request();
                                IDbCommand          command2 = conn2.CreateCommand("SHOW CREATE TABLE `" + view.Name + "`;");
                                using (IDataReader r2 = command2.ExecuteReader()) {
                                    r2.Read();
                                    view.Definition = r2.GetString(1);
                                }
                                conn2.Release();

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

            return(views);
        }
コード例 #13
0
        public override ViewSchemaCollection GetViews()
        {
            ViewSchemaCollection views = new ViewSchemaCollection();

            IPooledDbConnection conn    = connectionPool.Request();
            IDbCommand          command = conn.CreateCommand(
                "SELECT su.name AS owner, so.name as table_name, so.id as table_id, " +
                " so.crdate as created_date, so.xtype as table_type " +
                "FROM dbo.sysobjects so, dbo.sysusers su " +
                "WHERE xtype = 'V' " +
                "AND su.uid = so.uid " +
                "ORDER BY 1, 2"
                );

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

                            view.Name       = r.GetString(1);
                            view.SchemaName = r.GetString(0);
                            view.OwnerName  = r.GetString(0);

                            StringBuilder sb = new StringBuilder();
                            sb.AppendFormat("-- View: {0}\n", view.Name);
                            sb.AppendFormat("-- DROP VIEW {0};\n\n", view.Name);
                            sb.AppendFormat("  {0}\n);", GetSource("[" + view.OwnerName + "].[" + view.Name + "]"));
                            view.Definition = sb.ToString();

                            views.Add(view);
                        }
                        r.Close();
                    }
                }
            } catch (Exception e) {
                QueryService.RaiseException(e);
            }
            conn.Release();

            return(views);
        }
コード例 #14
0
		public ViewEditorDialog (ISchemaProvider schemaProvider, ViewSchema view, bool create)
		{
			if (schemaProvider == null)
				throw new ArgumentNullException ("schemaProvider");
			if (view == null)
				throw new ArgumentNullException ("view");
			
			this.schemaProvider = schemaProvider;
			this.view = view;
			this.action = create ? SchemaActions.Create : SchemaActions.Alter;
			
			this.Build();
			
			if (create)
				Title = GettextCatalog.GetString ("Create View");
			else
				Title = GettextCatalog.GetString ("Alter View");
			
			notebook = new Notebook ();

			sqlEditor = new SqlEditorWidget ();
			sqlEditor.TextChanged += new EventHandler (SqlChanged);
			notebook.AppendPage (sqlEditor, new Label (GettextCatalog.GetString ("Definition")));
			
			IDbFactory fac = schemaProvider.ConnectionPool.DbFactory;
			if (fac.IsCapabilitySupported ("View", action, ViewCapabilities.Comment)) {
				commentEditor = new CommentEditorWidget ();
				notebook.AppendPage (commentEditor, new Label (GettextCatalog.GetString ("Comment")));
			}

			notebook.Page = 0;

			entryName.Text = view.Name;
			if (!create) {
				sqlEditor.Text = schemaProvider.GetViewAlterStatement (view);
				commentEditor.Comment = view.Comment;
			}

			vboxContent.PackStart (notebook, true, true, 0);
			vboxContent.ShowAll ();
			SetWarning (null);
		}
コード例 #15
0
        public override ICollection <ViewSchema> GetViews()
        {
            CheckConnectionState();
            List <ViewSchema> views = new List <ViewSchema> ();

            IDbCommand command = connectionProvider.CreateCommand(
                "SELECT su.name AS owner, so.name as table_name, so.id as table_id, " +
                " so.crdate as created_date, so.type as table_type " +
                "FROM dbo.sysobjects so, dbo.sysusers su " +
                "WHERE type = 'V' " +
                "AND su.uid = so.uid " +
                "ORDER BY 1, 2"
                );

            using (command) {
                using (IDataReader r = command.ExecuteReader()) {
                    while (r.Read())
                    {
                        ViewSchema view = new ViewSchema(this);

                        view.Name         = r.GetString(1);
                        view.SchemaName   = r.GetString(0);
                        view.OwnerName    = r.GetString(0);
                        view.IsSystemView = r.GetString(4).Trim().Equals("S");

                        StringBuilder sb = new StringBuilder();
                        sb.AppendFormat("-- View: {0}\n", view.Name);
                        sb.AppendFormat("-- DROP VIEW {0};\n\n", view.Name);
                        string source = GetSource(view.Owner + "." + view.Name);
                        sb.AppendFormat("  {0}\n);", source);
                        view.Definition = sb.ToString();
                        //view.Comment = r.GetString(5);

                        views.Add(view);
                    }
                    r.Close();
                }
                connectionProvider.Close(command.Connection);
            }
            return(views);
        }
コード例 #16
0
        public virtual ColumnSchemaCollection GetViewColumns(ViewSchema view)
        {
            ColumnSchemaCollection collection = new ColumnSchemaCollection();

            IPooledDbConnection conn = connectionPool.Request();

            try {
                //restrictions: database, schema, table, column
                DataTable dt = conn.GetSchema(viewColumnsCollectionString, null, view.SchemaName, view.Name);
                for (int r = 0; r < dt.Rows.Count; r++)
                {
                    DataRow row = dt.Rows[r];
                    collection.Add(GetViewColumn(row, view));
                }
            } catch (Exception e) {
                QueryService.RaiseException(e);
            }
            conn.Release();

            return(collection);
        }
コード例 #17
0
        public override ColumnSchemaCollection GetViewColumns(ViewSchema view)
        {
            ColumnSchemaCollection columns = new ColumnSchemaCollection();

            IPooledDbConnection conn    = connectionPool.Request();
            IDbCommand          command = conn.CreateCommand(
                "SELECT * FROM \"" + view.Name +
                "\" WHERE 1 = 0"
                );

            try {
                using (command) {
                    using (IDataReader r = command.ExecuteReader()) {
                        for (int i = 0; i < r.FieldCount; i++)
                        {
                            ColumnSchema column = new ColumnSchema(this, view);

                            column.Name         = r.GetName(i);
                            column.DataTypeName = r.GetDataTypeName(i);
                            column.DefaultValue = "";
                            column.Definition   = "";
                            column.OwnerName    = view.OwnerName;
                            column.SchemaName   = view.OwnerName;

                            columns.Add(column);
                        }
                        r.Close();
                    }
                }
            } catch (Exception e) {
                QueryService.RaiseException(e);
            }
            conn.Release();

            return(columns);
        }
コード例 #18
0
		public override ICollection<ViewSchema> GetViews ()
		{
			CheckConnectionState ();
			List<ViewSchema> views = new List<ViewSchema> ();

			IDbCommand command = connectionProvider.CreateCommand (
				"SELECT RDB$RELATION_NAME, RDB$SYSTEM_FLAG, RDB$OWNER_NAME, RDB$DESCRIPTION, RDB$VIEW_SOURCE FROM RDB$RELATIONS "+
				"WHERE RDB$VIEW_SOURCE IS NOT NULL;"
			);
			using (command) {
				using (IDataReader r = command.ExecuteReader()) {
					while (r.Read ()) {
						ViewSchema view = new ViewSchema (this);
	
						view.Name = r.GetString (0);
						view.IsSystemView = (!r.IsDBNull (1) && r.GetInt32 (1) != 0);
						view.OwnerName = r.GetString (2);
						view.Comment = r.GetString (3);
						//TODO: view.Definition = 4 (ascii blob)

						views.Add (view);
					}
					r.Close ();
				}
				connectionProvider.Close (command.Connection);
			}
			return views;
コード例 #19
0
		public override ICollection<ColumnSchema> GetViewColumns (ViewSchema view)
		{
			return GetTableOrViewColumns (view.Name);
コード例 #20
0
		public virtual string GetViewAlterStatement (ViewSchema view)
		{
			throw new NotImplementedException ();
		}
コード例 #21
0
		public bool ShowViewEditorDialog (ISchemaProvider schemaProvider, ViewSchema view, bool create)
		{
			return RunDialog (new ViewEditorDialog (schemaProvider, view, create));
コード例 #22
0
		//http://www.sqlite.org/lang_createview.html
		public override void CreateView (ViewSchema view)
		{
			IPooledDbConnection conn = connectionPool.Request ();
			IDbCommand command = conn.CreateCommand (view.Definition);
			using (command)
				conn.ExecuteNonQuery (command);
			conn.Release ();
		}
コード例 #23
0
		public override string GetViewAlterStatement (ViewSchema view)
		{
			return String.Concat ("DROP VIEW IF EXISTS ", view.Name, "; ", Environment.NewLine, view.Definition); 
		}
コード例 #24
0
		//http://www.postgresql.org/docs/8.2/interactive/sql-altertable.html
		public override void RenameView (ViewSchema view, string name)
		{
			//this is no copy paste error, it really is "ALTER TABLE"
			ExecuteNonQuery ("ALTER TABLE " + view.Name + " RENAME TO " + name + ";");
			
			view.Name = name;
コード例 #25
0
 public bool ShowViewEditorDialog(ISchemaProvider schemaProvider, ViewSchema view, bool create)
 {
     return(RunDialog(new ViewEditorDialog(schemaProvider, view, create)));
 }
コード例 #26
0
		
		public override string GetViewAlterStatement (ViewSchema view)
		{
			//'CREATE ' <-- after this we insert
			return view.Definition.Insert (6, "OR REPLACE ");
コード例 #27
0
 public override ICollection <ColumnSchema> GetViewColumns(ViewSchema view)
 {
     return(GetTableOrViewColumns(view.Name));
 }
コード例 #28
0
		public override ICollection<ViewSchema> GetViews ()
		{
			CheckConnectionState ();
			List<ViewSchema> views = new List<ViewSchema> ();

			IDbCommand command = connectionProvider.CreateCommand (
				"SELECT OWNER, VIEW_NAME, TEXT " +
				"FROM ALL_VIEWS " +
				"ORDER BY OWNER, VIEW_NAME"
			);
			using (command) {
				using (IDataReader r = command.ExecuteReader()) {
					while (r.Read ()) {
						ViewSchema view = new ViewSchema (this);
	
						view.Name = r.GetString(1);
						view.SchemaName = r.GetString (0);
						view.OwnerName = r.GetString (0);
						view.Definition = r.GetString (2);
						view.IsSystemView = IsSystem (view.OwnerName);
						
						views.Add (view);
					}
					r.Close ();
				}
				connectionProvider.Close (command.Connection);
			}
			return views;
コード例 #29
0
		public override ViewSchemaCollection GetViews ()
		{
			ViewSchemaCollection views = new ViewSchemaCollection ();
			
			IPooledDbConnection conn = connectionPool.Request ();
			IDbCommand command = conn.CreateCommand (
				"SELECT name, sql FROM sqlite_master WHERE type = 'views'"
			);
			try {
				using (command) {
					using (IDataReader r = command.ExecuteReader()) {
						while (r.Read ()) {
							ViewSchema view = new ViewSchema (this);
		
							view.SchemaName = "main";
							view.Name = r.GetString (0);
							view.Definition = r.GetString (1);
							
							views.Add (view);
						}
						r.Close ();
					}
				}
			} catch (Exception e) {
				QueryService.RaiseException (e);
			}
			conn.Release ();

			return views;
		}
コード例 #30
0
		public override ICollection<ViewSchema> GetViews ()
		{
			CheckConnectionState ();
			List<ViewSchema> views = new List<ViewSchema> ();

			IDbCommand command = connectionProvider.CreateCommand (
				"SELECT su.name AS owner, so.name as table_name, so.id as table_id, " +
				" so.crdate as created_date, so.type as table_type " +
				"FROM dbo.sysobjects so, dbo.sysusers su " +
				"WHERE type = 'V' " +
				"AND su.uid = so.uid " +
				"ORDER BY 1, 2"
			);
			using (command) {
				using (IDataReader r = command.ExecuteReader()) {
					while (r.Read ()) {
						ViewSchema view = new ViewSchema (this);
	
						view.Name = r.GetString (1);
						view.SchemaName = r.GetString (0);
						view.OwnerName = r.GetString (0);
						view.IsSystemView = r.GetString (4).Trim ().Equals ("S");
						
						StringBuilder sb = new StringBuilder ();
						sb.AppendFormat ("-- View: {0}\n", view.Name);
						sb.AppendFormat ("-- DROP VIEW {0};\n\n", view.Name);
						string source = GetSource (view.Owner + "." + view.Name);
						sb.AppendFormat ("  {0}\n);", source);
						view.Definition = sb.ToString ();
						//view.Comment = r.GetString(5);
						
						views.Add (view);
					}
					r.Close ();
				}
				connectionProvider.Close (command.Connection);
			}
			return views;
コード例 #31
0
 //http://www.postgresql.org/docs/8.2/interactive/sql-dropview.html
 public override void DropView(ViewSchema view)
 {
     ExecuteNonQuery("DROP VIEW IF EXISTS " + view.Name + ";");
 }
コード例 #32
0
		//http://www.postgresql.org/docs/8.2/interactive/sql-createview.html
		public override void CreateView (ViewSchema view)
		{
			throw new NotImplementedException ();
コード例 #33
0
		//http://www.sqlite.org/lang_dropview.html
		public override void DropView (ViewSchema view)
		{
			ExecuteNonQuery ("DROP VIEW IF EXISTS " + view.Name);
		}
コード例 #34
0
 public virtual void RenameView(ViewSchema view, string name)
 {
     throw new NotImplementedException();
 }
コード例 #35
0
ファイル: FakeNodes.cs プロジェクト: Kalnor/monodevelop
		public ViewNode (DatabaseConnectionContext context, ViewSchema view)
			: base (context)
		{
			if (view == null)
				throw new ArgumentNullException ("view");
			
			this.view = view;
		}
コード例 #36
0
 public override string GetViewAlterStatement(ViewSchema view)
 {
     //'CREATE ' <-- after this we insert
     return(view.Definition.Insert(6, "OR REPLACE "));
 }
コード例 #37
0
 //http://msdn2.microsoft.com/en-us/library/aa225939(SQL.80).aspx
 public override void AlterView(ViewSchema view)
 {
     ExecuteNonQuery(view.Definition);
 }
コード例 #38
0
 //http://msdn2.microsoft.com/en-US/library/aa238878(SQL.80).aspx
 public override void RenameView(ViewSchema view, string name)
 {
     Rename(view.Name, name, "OBJECT");
     view.Name = name;
 }
コード例 #39
0
 public virtual void DropView(ViewSchema view)
 {
     throw new NotImplementedException();
 }
コード例 #40
0
		public override ColumnSchemaCollection GetViewColumns (ViewSchema view)
		{
			ColumnSchemaCollection columns = new ColumnSchemaCollection ();
			
			IPooledDbConnection conn = connectionPool.Request ();
			IDbCommand command = conn.CreateCommand (
				"SELECT attname, typname, attlen, attnotnull "
				+ "FROM "
				+ "  pg_catalog.pg_attribute a LEFT JOIN pg_catalog.pg_attrdef adef "
				+ "  ON a.attrelid=adef.adrelid "
				+ "  AND a.attnum=adef.adnum "
				+ "  LEFT JOIN pg_catalog.pg_type t ON a.atttypid=t.oid "
				+ "WHERE "
				+ "  a.attrelid = (SELECT oid FROM pg_catalog.pg_class WHERE relname='"
				+ view.Name + "') "
				+ "  AND a.attnum > 0 AND NOT a.attisdropped "
				+ "     ORDER BY a.attnum;"
			);
			try {
				using (command) {
					using (IDataReader r = command.ExecuteReader()) {
						while (r.Read ()) {
							ColumnSchema column = new ColumnSchema (this, view);

							column.Name = r.GetString(0);
							column.DataTypeName = r.GetString (1);
							column.SchemaName = view.SchemaName;
							column.IsNullable = r.GetBoolean (3);
							column.DataType.LengthRange.Default = r.GetInt32 (2);
			
							columns.Add (column);
						}
						r.Close ();
					};
				}
			} catch (Exception e) {
				QueryService.RaiseException (e);
			}
			conn.Release ();

			return columns;
コード例 #41
0
 public virtual string GetViewAlterStatement(ViewSchema view)
 {
     throw new NotImplementedException();
 }
コード例 #42
0
		public override ICollection<ColumnSchema> GetViewColumns (ViewSchema view)
		{
			CheckConnectionState ();
			List<ColumnSchema> columns = new List<ColumnSchema> ();
			
			//TODO:
			return columns;
コード例 #43
0
		public override ICollection<ColumnSchema> GetViewColumns (ViewSchema view)
		{
			CheckConnectionState ();
			List<ColumnSchema> columns = new List<ColumnSchema> ();
			
			IDbCommand command = connectionProvider.CreateCommand (
				"SELECT * " +
				" FROM " + view.Name +
				" WHERE 1 = 0"
			);
			using (command) {
				using (IDataReader r = command.ExecuteReader()) {
					while (r.Read ()) {
						for (int i = 0; i < r.FieldCount; i++) {
							ColumnSchema column = new ColumnSchema (this);
							
							column.Name = r.GetString (0);
							column.DataTypeName = r.GetString (1);
							column.SchemaName = view.SchemaName;
							column.NotNull = r.GetBoolean (3);
							column.Length = r.GetInt32 (2);
							
							columns.Add (column);
						}
					}
					r.Close ();
				};
				connectionProvider.Close (command.Connection);
			}

			return columns;
コード例 #44
0
		protected virtual ViewSchema GetView (DataRow row)
		{
			ViewSchema schema = new ViewSchema (this);
	
			schema.SchemaName = GetRowString (row, viewItemStrings[0]);
			schema.Name = GetRowString (row, viewItemStrings[1]);
			schema.Comment = GetRowString (row, viewItemStrings[2]);
			
			return schema;
		}
コード例 #45
0
		public override object Clone ()
		{
			ViewSchema clone = new ViewSchema (this);
			if (clone.columns != null) {
				foreach (ColumnSchema column in clone.columns)
					column.Parent = clone;
			}
			return clone;
		}
コード例 #46
0
		public virtual ColumnSchemaCollection GetViewColumns (ViewSchema view)
		{
			ColumnSchemaCollection collection = new ColumnSchemaCollection ();
			
			IPooledDbConnection conn = connectionPool.Request ();
			try {
				//restrictions: database, schema, table, column
				DataTable dt = conn.GetSchema (viewColumnsCollectionString, null, view.SchemaName, view.Name);
				for (int r = 0; r < dt.Rows.Count; r++) {
					DataRow row = dt.Rows[r];
					collection.Add (GetViewColumn (row, view));
				}
			} catch (Exception e) {
				QueryService.RaiseException (e);
			}
			conn.Release ();
			
			return collection;
		}
コード例 #47
0
		protected virtual ColumnSchema GetViewColumn (DataRow row, ViewSchema view)
		{
			ColumnSchema schema = new ColumnSchema (this, view);
			
			schema.SchemaName = view.SchemaName;
			schema.Name = GetRowString (row, viewColumnItemStrings[0]);
			
			return schema;
		}
コード例 #48
0
		public virtual void DropView (ViewSchema view)
		{
			throw new NotImplementedException ();
		}
コード例 #49
0
 //http://msdn2.microsoft.com/en-us/library/aa258254(SQL.80).aspx
 public override void CreateView(ViewSchema view)
 {
     throw new NotImplementedException();
 }
コード例 #50
0
		public virtual void RenameView (ViewSchema view, string name)
		{
			throw new NotImplementedException ();
		}
コード例 #51
0
 //http://msdn2.microsoft.com/en-us/library/aa258835(SQL.80).aspx
 public override void DropView(ViewSchema view)
 {
     ExecuteNonQuery("DROP VIEW " + view.Name);
 }
コード例 #52
0
		public virtual ViewSchema GetNewViewSchema (string name)
		{
			ViewSchema schema = new ViewSchema (this);
			schema.Name = name;
			return schema;
		}
コード例 #53
0
 public override string GetViewAlterStatement(ViewSchema view)
 {
     return(String.Concat("DROP VIEW ", view.Name, "; ", Environment.NewLine, view.Definition));
 }
コード例 #54
0
		public override ViewSchemaCollection GetViews ()
		{
			ViewSchemaCollection views = new ViewSchemaCollection ();

			IPooledDbConnection conn = connectionPool.Request ();
			IDbCommand command = conn.CreateCommand (
				"SELECT v.schemaname, v.viewname, v.viewowner, v.definition,"
				+ " (c.oid <= " + LastSystemOID + "), "
				+ "(SELECT description from pg_description pd, "
				+ " pg_class pc WHERE pc.oid=pd.objoid AND pc.relname="
				+ " v.viewname) "
				+ "FROM pg_views v, pg_class c "
				+ "WHERE v.viewname = c.relname "
				+ "ORDER BY viewname"
			);

			try {
				using (command) {
					using (IDataReader r = command.ExecuteReader()) {
						while (r.Read ()) {
							ViewSchema view = new ViewSchema (this);
		
							view.Name = r.GetString (1);
							view.OwnerName = r.GetString (2);
							view.SchemaName = r.GetString (0);
							view.IsSystemView = r.GetBoolean (4);
							view.Comment = r.IsDBNull (5) ? null : r.GetString (5);
							
//							StringBuilder sb = new StringBuilder();
//							sb.AppendFormat ("-- View: {0}\n", view.Name);
//							sb.AppendFormat ("-- DROP VIEW {0};\n\n", view.Name);
//							sb.AppendFormat ("CREATE VIEW {0} AS (\n", view.Name);
//							string core = r.GetString(3);
//							sb.AppendFormat ("  {0}\n);", core.Substring (0, core.Length-1));
//							view.Definition = sb.ToString ();
							
							views.Add (view);
						}
						r.Close ();
					}
				}
			} catch (Exception e) {
				QueryService.RaiseException (e);
			}
			conn.Release ();
			
			return views;