Ejemplo n.º 1
0
		public MetaTableCollection GetTables(bool includeSystemTables) 
		{
			if(con.State != ConnectionState.Open)
				con.Open();

			MetaTableCollection tables = new MetaTableCollection ();

			string where;
			if(includeSystemTables == true)
				where = "";
			else
				where = "WHERE OWNER NOT IN ('SYS','SYSTEM','MDSYS','CTXSYS','WMSYS','WKSYS')";

			string sql = "SELECT OWNER, TABLE_NAME, TABLESPACE_NAME " +
						 "FROM ALL_TABLES " +
						 where + 
						 " ORDER BY 1, 2";

			IDbCommand cmd = con.CreateCommand();
			cmd.CommandText = sql;

			IDataReader reader = cmd.ExecuteReader();
			while(reader.Read())
			{
				MetaTable table = new MetaTable(reader.GetString(0),
					reader.GetString(1));
				tables.Add(table);
			}
			reader.Close();
			reader = null;
			
			return tables;
		}
Ejemplo n.º 2
0
		public MetaTableCollection GetTables(bool includeSystemTables) 
		{
			if(con.State != ConnectionState.Open)
				con.Open();

			MetaTableCollection tables = new MetaTableCollection ();

			string sql = 
				"SELECT name " +
				"FROM sqlite_master " +
				"WHERE type = 'table' " +
				"ORDER BY name";

			IDbCommand cmd = con.CreateCommand();
			cmd.CommandText = sql;

			IDataReader reader = cmd.ExecuteReader();
			while(reader.Read())
			{
				MetaTable table = new MetaTable(reader.GetString(0));
				tables.Add(table);
			}
			reader.Close();
			reader = null;
			
			return tables;
		}
Ejemplo n.º 3
0
		public MetaTableCollection GetTables(bool includeSystemTables) 
		{
			if(con.State != ConnectionState.Open)
				con.Open();

			MetaTableCollection tables = new MetaTableCollection ();

			string sql = 
				"select schemaname, tablename " +
				"from pg_tables";

			sql = sql + " ORDER BY 1,2";

			IDbCommand cmd = con.CreateCommand();
			cmd.CommandText = sql;

			IDataReader reader = cmd.ExecuteReader();
			while(reader.Read()) {
				MetaTable table = new MetaTable(reader.GetString(0), reader.GetString(1));
				tables.Add(table);
			}
			reader.Close();
			reader = null;
			
			return tables;
		}
Ejemplo n.º 4
0
		public MetaTableCollection GetTables(bool includeSystemTables) 
		{
			if(con.State != ConnectionState.Open)
				con.Open();

			MetaTableCollection tables = new MetaTableCollection ();
			DataTable table = GetSchema ("Tables", new string[] {null, null, null, "TABLE"});

			for (int r = 0; r < table.Rows.Count; r++) 
			{
				DataRow row = table.Rows[r];
				string tableName = row["TABLE_NAME"].ToString();
				MetaTable mtable = new MetaTable(tableName);
				tables.Add(mtable);
			}
			
			return tables;
		}
Ejemplo n.º 5
0
		public MetaTableCollection GetTables(bool includeSystemTables) 
		{
			if(con.State != ConnectionState.Open)
				con.Open();

			MetaTableCollection tables = new MetaTableCollection ();

			string sql  = "";
			if (infoSchemaExists)
				sql = "select table_schema, table_name, " +
					" table_type from INFORMATION_SCHEMA.TABLES";
			else
				sql = "SHOW TABLES";

			IDbCommand cmd = con.CreateCommand();
			cmd.CommandText = sql;

			IDataReader reader = null;
			try {
				reader = cmd.ExecuteReader();
			}
			catch(Exception e) {
				infoSchemaExists = false;
				sql = "SHOW TABLES";
				reader = cmd.ExecuteReader();
			}

			while (reader.Read ()) {
				MetaTable table = null;
				
				if (infoSchemaExists)
					table = new MetaTable (reader.GetString (0), reader.GetString (1));
				else
					table = new MetaTable (reader.GetString (0));

				tables.Add(table);
			}
			reader.Close( );
			reader = null;
			
			return tables;
		}
Ejemplo n.º 6
0
		public MetaTableCollection GetTables(bool includeSystemTables) 
		{
			if(con.State != ConnectionState.Open)
				con.Open();

			MetaTableCollection tables = new MetaTableCollection ();

			string where;
			if(includeSystemTables == true)
				where = "'U','S'";
			else
				where = "'U'";

			string sql = 
				"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 IN (" + where + ") " +
				"AND su.uid = so.uid " +
				"ORDER BY 1, 2";

			IDbCommand cmd = con.CreateCommand();
			cmd.CommandText = sql;

			IDataReader reader = cmd.ExecuteReader();
			while(reader.Read())
			{
				MetaTable table = new MetaTable(reader.GetString(0),
					reader.GetString(1));
				tables.Add(table);
			}
			reader.Close();
			reader = null;
			
			return tables;
		}
Ejemplo n.º 7
0
		void OnDataTreeRowExpanded (object o, RowExpandedArgs args) 
		{
			// 1 Connections
			// 2   conn1
			// 2   conn2
			// 3     Tables
			// 4        table_name_display1, is_populated_status, table_owner, table_name
			// 4        table_name_display2, is_populated_status, table_owner, table_name
			// 5           Columns
			// 6              column_name1
			// 6              column_name2

			// RowExpandedArgs has:
			//  args.Iter
			//  args.Path

			TreeModel model = (TreeModel) tree.Store;

			if (args.Path.Depth == 5) 
			{
				string val = (string) model.GetValue (args.Iter, 0);
				if (val.Equals("Columns"))
				{
					TreeIter parent = args.Iter;
					TreeIter dataSourceIter = args.Iter;

					// get table name
					model.IterParent(out parent, args.Iter);
					string tableName = (string) tree.Store.GetValue (parent, 0); // tableName display
					string objOwner = (string) tree.Store.GetValue (parent, 2); // owner name
					string objName = (string) tree.Store.GetValue (parent, 3); // table name

					TreeIter iter;
					iter = parent;
					model.IterParent(out parent, iter);
					val = (string) tree.Store.GetValue (parent, 0); // Tables
					if (val.Equals("Tables")) 
					{
						// get data source
						model.IterParent(out dataSourceIter, parent);
						string dataSourceName = (string) model.GetValue (dataSourceIter, 0);
						ComboHelper.SetActiveText (combo, dataSourceName);
						
						TreeIter columnsIter = args.Iter;

						string populated = (string) tree.Store.GetValue (args.Iter, 1);
						if (!populated.Equals(NotPopulated))
							return;

						// setup schema browser
						Schema browser = new Schema (provider.Name, conn);
			
						if (browser.MetaData != null) 
						{
							SetStatusBarText ("Getting Meta Data: Tables Columns...");
							while (Application.EventsPending ()) 
								Application.RunIteration ();

							// get table columns
							MetaTable table = new MetaTable (objOwner, objName); // owner, tablename
							PopulateTableColumns(columnsIter, table, browser);

							model.SetValue (args.Iter, 1, "Populated");

							SetStatusBarText ("");

							// remove the NotPopulated node
							TreeIter popIter = columnsIter;
							if (tree.Store.IterChildren (out popIter, columnsIter)) 
								tree.Store.Remove (ref popIter);

						}
					}
				}
			}
		}
Ejemplo n.º 8
0
		public void PopulateTableColumns (TreeIter parentIter, MetaTable table, Schema browser) 
		{
			MetaTableColumnCollection columns = browser.GetTableColumns(table.Owner, table.Name);

			foreach(MetaTableColumn column in columns) {
				string nullable;
				if(column.Nullable == true)
					nullable = "Null";
				else
					nullable = "Not Null";
				
				string line = column.Name + " (" + 
					column.DataType + " (" + 
					column.Length + ", " +
					column.Precision + ", " + column.Scale + "), " +
					nullable + ")";
				tree.Store.AppendValues (parentIter, line, "");
			}		
		}