public virtual string TransformText() { #line 4 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.tt" if (DbmsPlatform == "SQL Server") { #line default #line hidden this.Write("IF OBJECT_ID(N\'"); #line 1 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(ObjectView)); #line default #line hidden this.Write("\', N\'V\') IS NULL\r\n\tEXECUTE (\'CREATE VIEW "); #line 2 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(ObjectView)); #line default #line hidden this.Write(" AS SELECT NULL AS CREATE_OR_REPLACE\');\r\nGO\r\n\r\nALTER VIEW "); #line 5 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(ObjectView)); #line default #line hidden this.Write(" AS\r\n-- This code was generated by "); #line 6 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(TemplateName)); #line default #line hidden this.Write(" @ "); #line 6 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(DateTime.Now.ToString())); #line default #line hidden this.Write("\r\nWITH\r\n\tCTE_MAIN AS\r\n\t(\r\n\t\tSELECT\r\n\t\t\t"); #line 11 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(Junction_Columns)); #line default #line hidden this.Write(",\r\n\t\t\t"); #line 12 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(PivotColumn)); #line default #line hidden this.Write(",\r\n\t\t\t"); #line 13 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(MeasureColumn)); #line default #line hidden this.Write("\r\n\t\tFROM\r\n\t\t\t"); #line 15 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(SourceView)); #line default #line hidden this.Write("\r\n\t\tWHERE\r\n\t\t\t"); #line 17 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(PivotColumn)); #line default #line hidden this.Write("\tIN ("); #line 17 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(Value_List)); #line default #line hidden this.Write(")\r\n\t\t\t"); #line 18 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(SourceFilter.InsertRight("AND "))); #line default #line hidden this.Write("\r\n\t),\r\n\tJOIN_ON AS\r\n\t(\r\n\t\tSELECT DISTINCT\r\n\t\t\t"); #line 23 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(Junction_Columns)); #line default #line hidden this.Write("\r\n\t\tFROM\r\n\t\t\tCTE_MAIN\r\n\t)\r\n"); #line 27 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.SqlServer.sql" for (int i = 0; i < Value_Aliases.Length; i++) { #line default #line hidden this.Write("\t,\r\n\tCTE_"); #line 32 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(i)); #line default #line hidden this.Write("\tAS\r\n\t(\r\n\t\tSELECT\r\n\t\t\t"); #line 35 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(Junction_Columns)); #line default #line hidden this.Write(",\r\n\t\t\t"); #line 36 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(MeasureColumn)); #line default #line hidden this.Write("\r\n\t\tFROM\r\n\t\t\tCTE_MAIN\r\n\t\tWHERE\r\n\t\t\t"); #line 40 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(PivotColumn)); #line default #line hidden this.Write("\t= "); #line 40 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(Value_Aliases[i].Item1)); #line default #line hidden this.Write("\r\n\t)\r\n"); #line 42 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.SqlServer.sql" } #line default #line hidden this.Write("SELECT\r\n\tJ."); #line 46 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(Junction_Columns)); #line default #line hidden this.Write("\r\n"); #line 47 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.SqlServer.sql" for (int i = 0; i < Value_Aliases.Length; i++) { #line default #line hidden this.Write("\t, C"); #line 51 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(i)); #line default #line hidden this.Write("."); #line 51 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(MeasureColumn)); #line default #line hidden this.Write("\t\tAS "); #line 51 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(Value_Aliases[i].Item2)); #line default #line hidden this.Write("\r\n"); #line 52 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.SqlServer.sql" } #line default #line hidden this.Write("FROM\r\n\tJOIN_ON\t\tJ\r\n"); #line 57 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.SqlServer.sql" for (int i = 0; i < Value_Aliases.Length; i++) { #line default #line hidden this.Write("\tLEFT JOIN\r\n\tCTE_"); #line 62 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(i)); #line default #line hidden this.Write("\t\tC"); #line 62 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(i)); #line default #line hidden this.Write("\r\n\tON\t("); #line 63 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(string.Join(" AND ", JunctionColumns.Select(c => string.Format("J.{0} = C{1}.{0}", c, i))))); #line default #line hidden this.Write(")\r\n"); #line 64 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.SqlServer.sql" } #line default #line hidden this.Write(@"; GO ---------------------------------------------------------------------------------------------------- -- -- Copyright 2013 Abel Cheng -- This source code is subject to terms and conditions of the Apache License, Version 2.0. -- See http://www.apache.org/licenses/LICENSE-2.0. -- All other rights reserved. -- You must not remove this notice, or any other, from this software. -- -- Original Author: Abel Cheng <*****@*****.**> -- Created Date: November 26, 2013, 10:06:19 PM -- Primary Host: http://t4sql.codeplex.com -- Change Log: -- Author Date Comment -- -- -- -- -- (Keep code clean) -- ---------------------------------------------------------------------------------------------------- "); this.Write("\r\n"); #line 9 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.tt" } else if (DbmsPlatform == "Oracle") { #line default #line hidden this.Write("CREATE OR REPLACE VIEW "); #line 1 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(ObjectView)); #line default #line hidden this.Write(" AS\r\nWITH\r\n-- This code was generated by "); #line 3 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(TemplateName)); #line default #line hidden this.Write(" @ "); #line 3 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(DateTime.Now.ToString())); #line default #line hidden this.Write("\r\n\tCTE_MAIN AS\r\n\t(\r\n\t\tSELECT\r\n\t\t\t"); #line 7 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(Junction_Columns)); #line default #line hidden this.Write(",\r\n\t\t\t"); #line 8 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(PivotColumn)); #line default #line hidden this.Write(",\r\n\t\t\t"); #line 9 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(MeasureColumn)); #line default #line hidden this.Write("\r\n\t\tFROM\r\n\t\t\t"); #line 11 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(SourceView)); #line default #line hidden this.Write("\r\n\t\tWHERE\r\n\t\t\t"); #line 13 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(PivotColumn)); #line default #line hidden this.Write("\tIN ("); #line 13 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(Value_List)); #line default #line hidden this.Write(")\r\n\t\t\t"); #line 14 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(SourceFilter.InsertRight("AND "))); #line default #line hidden this.Write("\r\n\t),\r\n\tJOIN_ON AS\r\n\t(\r\n\t\tSELECT DISTINCT\r\n\t\t\t"); #line 19 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(Junction_Columns)); #line default #line hidden this.Write("\r\n\t\tFROM\r\n\t\t\tCTE_MAIN\r\n\t)\r\n"); #line 23 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.Oracle.sql" for (int i = 0; i < Value_Aliases.Length; i++) { #line default #line hidden this.Write("\t,\r\n\tCTE_"); #line 28 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(i)); #line default #line hidden this.Write("\tAS\r\n\t(\r\n\t\tSELECT\r\n\t\t\t"); #line 31 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(Junction_Columns)); #line default #line hidden this.Write(",\r\n\t\t\t"); #line 32 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(MeasureColumn)); #line default #line hidden this.Write("\r\n\t\tFROM\r\n\t\t\tCTE_MAIN\r\n\t\tWHERE\r\n\t\t\t"); #line 36 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(PivotColumn)); #line default #line hidden this.Write("\t= "); #line 36 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(Value_Aliases[i].Item1)); #line default #line hidden this.Write("\r\n\t)\r\n"); #line 38 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.Oracle.sql" } #line default #line hidden this.Write("SELECT\r\n\tJ."); #line 42 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(Junction_Columns)); #line default #line hidden this.Write("\r\n"); #line 43 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.Oracle.sql" for (int i = 0; i < Value_Aliases.Length; i++) { #line default #line hidden this.Write("\t, C"); #line 47 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(i)); #line default #line hidden this.Write("."); #line 47 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(MeasureColumn)); #line default #line hidden this.Write("\t\tAS "); #line 47 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(Value_Aliases[i].Item2)); #line default #line hidden this.Write("\r\n"); #line 48 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.Oracle.sql" } #line default #line hidden this.Write("FROM\r\n\tJOIN_ON\t\tJ\r\n"); #line 53 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.Oracle.sql" for (int i = 0; i < Value_Aliases.Length; i++) { #line default #line hidden this.Write("\tLEFT JOIN\r\n\tCTE_"); #line 58 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(i)); #line default #line hidden this.Write("\t\tC"); #line 58 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(i)); #line default #line hidden this.Write("\r\n\tON\t("); #line 59 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(string.Join(" AND ", JunctionColumns.Select(c => string.Format("J.{0} = C{1}.{0}", c, i))))); #line default #line hidden this.Write(")\r\n"); #line 60 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.Oracle.sql" } #line default #line hidden this.Write(@"WITH READ ONLY; ---------------------------------------------------------------------------------------------------- -- -- Copyright 2013 Abel Cheng -- This source code is subject to terms and conditions of the Apache License, Version 2.0. -- See http://www.apache.org/licenses/LICENSE-2.0. -- All other rights reserved. -- You must not remove this notice, or any other, from this software. -- -- Original Author: Abel Cheng <*****@*****.**> -- Created Date: November 26, 2013, 10:06:19 PM -- Primary Host: http://t4sql.codeplex.com -- Change Log: -- Author Date Comment -- -- -- -- -- (Keep code clean) -- ---------------------------------------------------------------------------------------------------- "); this.Write("\r\n"); #line 15 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.tt" } else { Error("T4SQL.Pivot.VFullPivot is not implemented for " + DbmsPlatform); } #line default #line hidden #line 21 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VFullPivot.tt" /* * Before building the project or checking in code, if any included file changes, * you should re-transform the including template in the solution by: * * Right-click one or more files in Solution Explorer and then click Run Custom Tool. * Use this method to transform a selected set of templates. * or * Click Transform All Templates in the Solution Explorer toolbar. * This will transform all the templates in the Visual Studio solution. * or * Installed Visual Studio Visualization and Modeling SDK * http://archive.msdn.microsoft.com/vsvmsdk, * And setup all the templates transformed automatically: * http://msdn.microsoft.com/en-us/library/dd820620.aspx#Regenerating * http://msdn.microsoft.com/en-us/library/ee847423.aspx * http://msdn.microsoft.com/en-us/library/ff521399.aspx */ #line default #line hidden return(this.GenerationEnvironment.ToString()); }
public virtual string TransformText() { #line 4 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VPivot.tt" if (DbmsPlatform == "SQL Server") { #line default #line hidden this.Write("IF OBJECT_ID(N\'"); #line 1 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VPivot.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(ObjectView)); #line default #line hidden this.Write("\', N\'V\') IS NULL\r\n\tEXECUTE (\'CREATE VIEW "); #line 2 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VPivot.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(ObjectView)); #line default #line hidden this.Write(" AS SELECT NULL AS CREATE_OR_REPLACE\');\r\nGO\r\n\r\nALTER VIEW "); #line 5 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VPivot.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(ObjectView)); #line default #line hidden this.Write(" AS\r\n-- This code was generated by "); #line 6 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VPivot.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(TemplateName)); #line default #line hidden this.Write(" @ "); #line 6 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VPivot.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(DateTime.Now.ToString())); #line default #line hidden this.Write("\r\nSELECT\r\n\t"); #line 8 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VPivot.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(SelectColumns)); #line default #line hidden this.Write("\r\nFROM\r\n(\r\n\tSELECT\r\n\t\t"); #line 12 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VPivot.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(SourceColumns)); #line default #line hidden this.Write("\r\n\tFROM\r\n\t\t"); #line 14 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VPivot.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(SourceView)); #line default #line hidden this.Write("\r\n\t"); #line 15 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VPivot.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(SourceFilter.InsertRight("WHERE\r\n "))); #line default #line hidden this.Write("\r\n)\tS\r\nPIVOT\r\n(\r\n\t"); #line 19 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VPivot.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(AggregateFunction)); #line default #line hidden this.Write("\r\n\tFOR "); #line 20 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VPivot.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(PivotColumn)); #line default #line hidden this.Write(" IN ("); #line 20 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VPivot.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(ValueList)); #line default #line hidden this.Write(@") ) P ; GO ---------------------------------------------------------------------------------------------------- -- -- Copyright 2013 Abel Cheng -- This source code is subject to terms and conditions of the Apache License, Version 2.0. -- See http://www.apache.org/licenses/LICENSE-2.0. -- All other rights reserved. -- You must not remove this notice, or any other, from this software. -- -- Original Author: Abel Cheng <*****@*****.**> -- Created Date: June 02, 2013, 11:06:09 AM -- Primary Host: http://t4sql.codeplex.com -- Change Log: -- Author Date Comment -- -- -- -- -- (Keep code clean) -- ---------------------------------------------------------------------------------------------------- "); this.Write("\r\n"); #line 9 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VPivot.tt" } else if (DbmsPlatform == "Oracle") { #line default #line hidden this.Write("CREATE OR REPLACE VIEW "); #line 1 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VPivot.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(ObjectView)); #line default #line hidden this.Write(" AS\r\nSELECT\r\n\t-- This code was generated by "); #line 3 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VPivot.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(TemplateName)); #line default #line hidden this.Write(" @ "); #line 3 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VPivot.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(DateTime.Now.ToString())); #line default #line hidden this.Write("\r\n\t*\r\nFROM\r\n(\r\n\tSELECT\r\n\t\t"); #line 8 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VPivot.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(SourceColumns)); #line default #line hidden this.Write("\r\n\tFROM\r\n\t\t"); #line 10 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VPivot.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(SourceView)); #line default #line hidden this.Write("\r\n\t"); #line 11 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VPivot.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(SourceFilter.InsertRight("WHERE\r\n "))); #line default #line hidden this.Write("\r\n)\tS\r\nPIVOT\r\n(\r\n\t"); #line 15 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VPivot.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(AggregateFunction)); #line default #line hidden this.Write("\r\n\tFOR "); #line 16 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VPivot.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(PivotColumn)); #line default #line hidden this.Write(" IN ("); #line 16 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VPivot.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(Value_List)); #line default #line hidden this.Write(@") ) P WITH READ ONLY; ---------------------------------------------------------------------------------------------------- -- -- Copyright 2013 Abel Cheng -- This source code is subject to terms and conditions of the Apache License, Version 2.0. -- See http://www.apache.org/licenses/LICENSE-2.0. -- All other rights reserved. -- You must not remove this notice, or any other, from this software. -- -- Original Author: Abel Cheng <*****@*****.**> -- Created Date: June 02, 2013, 11:06:09 AM -- Primary Host: http://t4sql.codeplex.com -- Change Log: -- Author Date Comment -- -- -- -- -- (Keep code clean) -- ---------------------------------------------------------------------------------------------------- "); this.Write("\r\n"); #line 15 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VPivot.tt" } else { Error("T4SQL.Pivot.VPivot is not implemented for " + DbmsPlatform); } #line default #line hidden #line 21 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Pivot\VPivot.tt" /* * Before building the project or checking in code, if any included file changes, * you should re-transform the including template in the solution by: * * Right-click one or more files in Solution Explorer and then click Run Custom Tool. * Use this method to transform a selected set of templates. * or * Click Transform All Templates in the Solution Explorer toolbar. * This will transform all the templates in the Visual Studio solution. * or * Installed Visual Studio Visualization and Modeling SDK * http://archive.msdn.microsoft.com/vsvmsdk, * And setup all the templates transformed automatically: * http://msdn.microsoft.com/en-us/library/dd820620.aspx#Regenerating * http://msdn.microsoft.com/en-us/library/ee847423.aspx * http://msdn.microsoft.com/en-us/library/ff521399.aspx */ #line default #line hidden return(this.GenerationEnvironment.ToString()); }
public virtual string TransformText() { #line 4 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Inspection\VCheckUniqueness.tt" if (DbmsPlatform == "SQL Server") { #line default #line hidden this.Write("IF OBJECT_ID(N\'"); #line 1 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Inspection\VCheckUniqueness.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(ObjectView)); #line default #line hidden this.Write("\', N\'V\') IS NULL\r\n\tEXECUTE (\'CREATE VIEW "); #line 2 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Inspection\VCheckUniqueness.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(ObjectView)); #line default #line hidden this.Write(" AS SELECT NULL AS CREATE_OR_REPLACE\');\r\nGO\r\n\r\nALTER VIEW "); #line 5 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Inspection\VCheckUniqueness.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(ObjectView)); #line default #line hidden this.Write(" AS\r\n-- This code was generated by "); #line 6 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Inspection\VCheckUniqueness.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(TemplateName)); #line default #line hidden this.Write(" @ "); #line 6 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Inspection\VCheckUniqueness.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(DateTime.Now.ToString())); #line default #line hidden this.Write("\r\nSELECT\r\n\tT.*\r\n"); #line 9 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Inspection\VCheckUniqueness.SqlServer.sql" if (!string.IsNullOrWhiteSpace(KeyColumns)) { if (!string.IsNullOrWhiteSpace(OrderBy) && !string.IsNullOrWhiteSpace(RowNumberAlias)) { #line default #line hidden this.Write("\t, ROW_NUMBER() OVER (PARTITION BY "); #line 15 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Inspection\VCheckUniqueness.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(KeyColumns)); #line default #line hidden this.Write(" ORDER BY "); #line 15 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Inspection\VCheckUniqueness.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(OrderBy)); #line default #line hidden this.Write(") AS "); #line 15 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Inspection\VCheckUniqueness.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(RowNumberAlias)); #line default #line hidden this.Write("\r\n"); #line 16 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Inspection\VCheckUniqueness.SqlServer.sql" } if (!string.IsNullOrWhiteSpace(CountAlias)) { #line default #line hidden this.Write("\t, COUNT(*) OVER (PARTITION BY "); #line 22 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Inspection\VCheckUniqueness.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(KeyColumns)); #line default #line hidden this.Write(") AS "); #line 22 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Inspection\VCheckUniqueness.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(CountAlias)); #line default #line hidden this.Write("\r\n"); #line 23 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Inspection\VCheckUniqueness.SqlServer.sql" } } #line default #line hidden this.Write("FROM\r\n\t"); #line 28 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Inspection\VCheckUniqueness.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(SourceTable)); #line default #line hidden this.Write("\tT\r\n"); #line 29 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Inspection\VCheckUniqueness.SqlServer.sql" this.Write(this.ToStringHelper.ToStringWithCulture(SourceFilter.InsertRight("WHERE\r\n "))); #line default #line hidden this.Write(@"; GO ---------------------------------------------------------------------------------------------------- -- -- Copyright 2013 Abel Cheng -- This source code is subject to terms and conditions of the Apache License, Version 2.0. -- See http://www.apache.org/licenses/LICENSE-2.0. -- All other rights reserved. -- You must not remove this notice, or any other, from this software. -- -- Original Author: Abel Cheng <*****@*****.**> -- Created Date: January 13, 2014, 11:00:42 PM -- Primary Host: http://t4sql.codeplex.com -- Change Log: -- Author Date Comment -- -- -- -- -- (Keep code clean) -- ---------------------------------------------------------------------------------------------------- "); this.Write("\r\n"); #line 9 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Inspection\VCheckUniqueness.tt" } else if (DbmsPlatform == "Oracle") { #line default #line hidden this.Write("CREATE OR REPLACE VIEW "); #line 1 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Inspection\VCheckUniqueness.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(ObjectView)); #line default #line hidden this.Write(" AS\r\nSELECT\r\n-- This code was generated by "); #line 3 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Inspection\VCheckUniqueness.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(TemplateName)); #line default #line hidden this.Write(" @ "); #line 3 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Inspection\VCheckUniqueness.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(DateTime.Now.ToString())); #line default #line hidden this.Write("\r\n\tT.*\r\n"); #line 5 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Inspection\VCheckUniqueness.Oracle.sql" if (!string.IsNullOrWhiteSpace(KeyColumns)) { if (!string.IsNullOrWhiteSpace(OrderBy) && !string.IsNullOrWhiteSpace(RowNumberAlias)) { #line default #line hidden this.Write("\t, ROW_NUMBER() OVER (PARTITION BY "); #line 11 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Inspection\VCheckUniqueness.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(KeyColumns)); #line default #line hidden this.Write(" ORDER BY "); #line 11 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Inspection\VCheckUniqueness.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(OrderBy)); #line default #line hidden this.Write(") AS "); #line 11 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Inspection\VCheckUniqueness.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(RowNumberAlias)); #line default #line hidden this.Write("\r\n"); #line 12 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Inspection\VCheckUniqueness.Oracle.sql" } if (!string.IsNullOrWhiteSpace(CountAlias)) { #line default #line hidden this.Write("\t, COUNT(*) OVER (PARTITION BY "); #line 18 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Inspection\VCheckUniqueness.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(KeyColumns)); #line default #line hidden this.Write(") AS "); #line 18 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Inspection\VCheckUniqueness.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(CountAlias)); #line default #line hidden this.Write("\r\n"); #line 19 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Inspection\VCheckUniqueness.Oracle.sql" } } #line default #line hidden #line 23 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Inspection\VCheckUniqueness.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(RowidAlias.InsertRight(" , T.ROWID AS "))); #line default #line hidden this.Write("\r\nFROM\r\n\t"); #line 25 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Inspection\VCheckUniqueness.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(SourceTable)); #line default #line hidden this.Write("\tT\r\n"); #line 26 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Inspection\VCheckUniqueness.Oracle.sql" this.Write(this.ToStringHelper.ToStringWithCulture(SourceFilter.InsertRight("WHERE\r\n "))); #line default #line hidden this.Write(@" WITH READ ONLY; ---------------------------------------------------------------------------------------------------- -- -- Copyright 2013 Abel Cheng -- This source code is subject to terms and conditions of the Apache License, Version 2.0. -- See http://www.apache.org/licenses/LICENSE-2.0. -- All other rights reserved. -- You must not remove this notice, or any other, from this software. -- -- Original Author: Abel Cheng <*****@*****.**> -- Created Date: January 13, 2014, 11:00:42 PM -- Primary Host: http://t4sql.codeplex.com -- Change Log: -- Author Date Comment -- -- -- -- -- (Keep code clean) -- ---------------------------------------------------------------------------------------------------- "); this.Write("\r\n"); #line 15 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Inspection\VCheckUniqueness.tt" } else { Error("T4SQL.Inspection.VCheckUniqueness is not implemented for " + DbmsPlatform); } #line default #line hidden #line 21 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Inspection\VCheckUniqueness.tt" /* * Before building the project or checking in code, if any included file changes, * you should re-transform the including template in the solution by: * * Right-click one or more files in Solution Explorer and then click Run Custom Tool. * Use this method to transform a selected set of templates. * or * Click Transform All Templates in the Solution Explorer toolbar. * This will transform all the templates in the Visual Studio solution. * or * Installed Visual Studio Visualization and Modeling SDK * http://archive.msdn.microsoft.com/vsvmsdk, * And setup all the templates transformed automatically: * http://msdn.microsoft.com/en-us/library/dd820620.aspx#Regenerating * http://msdn.microsoft.com/en-us/library/ee847423.aspx * http://msdn.microsoft.com/en-us/library/ff521399.aspx */ #line default #line hidden return(this.GenerationEnvironment.ToString()); }