/// <summary> ///Get SQL Create View /// </summary> /// <param name="requery">refresh columns</param> /// <returns>create view DDL</returns> public String GetViewCreate(bool requery) { if (!IsView() || !IsActive()) { return(null); } StringBuilder sb = new StringBuilder("CREATE OR REPLACE VIEW ") .Append(GetTableName()); // this.GetViewComponent(requery); if (m_vcs == null || m_vcs.Length == 0) { return(null); } MViewColumn[] vCols = null; for (int i = 0; i < m_vcs.Length; i++) { MViewComponent vc = m_vcs[i]; if (i > 0) { sb.Append(" UNION "); } else { vCols = vc.GetColumns(requery); if (vCols == null || vCols.Length == 0) { return(null); } bool right = false; for (int j = 0; j < vCols.Length; j++) { if (vCols[j].GetColumnName().Equals("*")) { break; } if (j == 0) { sb.Append("("); right = true; } else { sb.Append(", "); } sb.Append(vCols[j].GetColumnName()); } if (right) { sb.Append(")"); } sb.Append(" AS "); } sb.Append(vc.GetSelect(false, vCols)); } return(sb.ToString()); }
/// <summary> /// Parent Constructor /// </summary> /// <param name="parent">parent</param> public MViewColumn(MViewComponent parent) : this(parent.GetCtx(), 0, parent.Get_TrxName()) { SetClientOrg(parent); SetAD_ViewComponent_ID(parent.GetAD_ViewComponent_ID()); } // MViewColumn