public static Collection <DBRelationInfo> QueryViewCatalog(DBSchemaInfo schema) { string SQL = null; object[] aParams = null; switch (schema.Source) { case dbOrigen.ORA: SQL = AdministradorPreferencias.Read(PrefsBD.ORACustomViewSchemaQuery); if (SQL == null || SQL.Trim() == string.Empty) { SQL = AdministradorPreferencias.Read(PrefsBD.ORADefaultViewSchemaQuery); } aParams = new object[] { schema.Name.Trim() }; break; case dbOrigen.PGSQL: SQL = AdministradorPreferencias.Read(PrefsBD.PGSQLCustomViewSchemaQuery); if (SQL == null || SQL.Trim() == string.Empty) { SQL = AdministradorPreferencias.Read(PrefsBD.PGSQLDefaultViewSchemaQuery); } aParams = new object[] { DBSettings.PGSQLDb, schema.Name.Trim() }; break; } DataSet ds = GetDataSet(schema.Source, SQL, aParams); Collection <DBRelationInfo> views = new Collection <DBRelationInfo>(); foreach (DataRow r in ds.Tables[0].Rows) { views.Add(new DBRelationInfo(schema, (string)r[0], dbRelationType.View)); } return(views); }
private static DBColumnInfo ColInfoFromName(dbOrigen source, string qualifiedName) { string[] names = qualifiedName.Split(new char[] { '.' }); string schemaName = string.Empty; string relationName = string.Empty; string columnName = string.Empty; switch (source) { case dbOrigen.PGSQL: //En PostgreSQL el esquema por defecto es 'public' schemaName = (names.Length > 2) ? names[0] : "public"; break; case dbOrigen.ORA: //En ORACLE el nombre debe ser completamente calificado //puesto que no existe el concepto de ESQUEMA como categoría. //En ORACLE ESQUEMA = NOMBRE_PROPIETARIO. Por tanto, si no //conocemos el nombre del propietario, la estructura DBColumnInfo //quedará incompleta. schemaName = (names.Length > 2) ? names[0] : string.Empty; break; } relationName = (names.Length > 2) ? names[1] : names[0]; columnName = (names.Length > 2) ? names[2] : names[1]; DBSchemaInfo schema = new DBSchemaInfo(source, schemaName); DBRelationInfo relation = new DBRelationInfo(schema, relationName, dbRelationType.Unknown); return(new DBColumnInfo(relation, columnName, string.Empty, string.Empty)); }
public DBRelationInfo(DBSchemaInfo schema, string name, dbRelationType type) { this.Schema = schema; this.Name = name; this.Type = type; }