Skip to content

Commit 46e77e1

Browse files
committed
VTimeRangesToSeries, VTimePointsToSeries, VTimeRangesCheckSum,
1 parent 2b050a1 commit 46e77e1

22 files changed

+665
-66
lines changed

T4SQLTemplateLibrary/T4Templates/Assoc/VNaviForeignKey.Oracle.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CREATE OR REPLACE VIEW <#= ObjectView #> AS
22
SELECT
3-
-- This code was generated by <#= TemplateName #> @ <#= DateTime.Now.ToString() #>
3+
-- This code was generated by <#= TemplateName #> @ <#= DateTime.Now.ToString() #>
44
<#= ColumnListClause #>
55
FROM
66
<#= JoinClause #>
@@ -15,7 +15,7 @@ WITH READ ONLY;
1515
-- You must not remove this notice, or any other, from this software.
1616
--
1717
-- Original Author: Abel Cheng <[email protected]>
18-
-- Created Date: ‎‎‎‎July 03, 2013, ‏‎12:56:08 AM
18+
-- Created Date: July 03, 2013, 12:56:08 AM
1919
-- Primary Host: http://t4sql.codeplex.com
2020
-- Change Log:
2121
-- Author Date Comment

T4SQLTemplateLibrary/T4Templates/Assoc/VNaviForeignKey.SqlServer.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ GO
1919
-- You must not remove this notice, or any other, from this software.
2020
--
2121
-- Original Author: Abel Cheng <[email protected]>
22-
-- Created Date: ‎‎‎July 03, 2013, ‏‎12:56:08 AM
22+
-- Created Date: July 03, 2013, 12:56:08 AM
2323
-- Primary Host: http://t4sql.codeplex.com
2424
-- Change Log:
2525
-- Author Date Comment

T4SQLTemplateLibrary/T4Templates/Assoc/VNaviForeignKey.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public virtual string TransformText()
9090
-- You must not remove this notice, or any other, from this software.
9191
--
9292
-- Original Author: Abel Cheng <[email protected]>
93-
-- Created Date: ‎‎‎July 03, 2013, ‏‎12:56:08 AM
93+
-- Created Date: July 03, 2013, 12:56:08 AM
9494
-- Primary Host: http://t4sql.codeplex.com
9595
-- Change Log:
9696
-- Author Date Comment
@@ -120,7 +120,7 @@ public virtual string TransformText()
120120

121121
#line default
122122
#line hidden
123-
this.Write(" AS\r\nSELECT\r\n-- This code was generated by ");
123+
this.Write(" AS\r\nSELECT\r\n\t-- This code was generated by ");
124124

125125
#line 3 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Assoc\VNaviForeignKey.Oracle.sql"
126126
this.Write(this.ToStringHelper.ToStringWithCulture(TemplateName));
@@ -160,7 +160,7 @@ public virtual string TransformText()
160160
-- You must not remove this notice, or any other, from this software.
161161
--
162162
-- Original Author: Abel Cheng <[email protected]>
163-
-- Created Date: ‎‎‎‎July 03, 2013, ‏‎12:56:08 AM
163+
-- Created Date: July 03, 2013, 12:56:08 AM
164164
-- Primary Host: http://t4sql.codeplex.com
165165
-- Change Log:
166166
-- Author Date Comment

T4SQLTemplateLibrary/T4Templates/Date/VTimePointsToRanges.Oracle.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CREATE OR REPLACE VIEW <#= ObjectView #> AS
22
SELECT
3-
-- This code was generated by <#= TemplateName #> @ <#= DateTime.Now.ToString() #>
3+
-- This code was generated by <#= TemplateName #> @ <#= DateTime.Now.ToString() #>
44
<#
55
string tEndDateCol = IsEndDateNext ? DateColumn : string.Format("({0} - 1)", DateColumn);
66
#>
@@ -22,7 +22,7 @@ WITH READ ONLY;
2222
-- You must not remove this notice, or any other, from this software.
2323
--
2424
-- Original Author: Abel Cheng <[email protected]>
25-
-- Created Date: May 20, 2013, ‏‎12:00:44 AM
25+
-- Created Date: May 20, 2013, 12:00:44 AM
2626
-- Primary Host: http://t4sql.codeplex.com
2727
-- Change Log:
2828
-- Author Date Comment

T4SQLTemplateLibrary/T4Templates/Date/VTimePointsToRanges.SqlServer.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ GO
5555
-- You must not remove this notice, or any other, from this software.
5656
--
5757
-- Original Author: Abel Cheng <[email protected]>
58-
-- Created Date: May 20, 2013, ‏‎12:00:44 AM
58+
-- Created Date: May 20, 2013, 12:00:44 AM
5959
-- Primary Host: http://t4sql.codeplex.com
6060
-- Change Log:
6161
-- Author Date Comment

T4SQLTemplateLibrary/T4Templates/Date/VTimePointsToRanges.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ public virtual string TransformText()
236236
-- You must not remove this notice, or any other, from this software.
237237
--
238238
-- Original Author: Abel Cheng <[email protected]>
239-
-- Created Date: May 20, 2013, ‏‎12:00:44 AM
239+
-- Created Date: May 20, 2013, 12:00:44 AM
240240
-- Primary Host: http://t4sql.codeplex.com
241241
-- Change Log:
242242
-- Author Date Comment
@@ -266,7 +266,7 @@ public virtual string TransformText()
266266

267267
#line default
268268
#line hidden
269-
this.Write(" AS\r\nSELECT\r\n-- This code was generated by ");
269+
this.Write(" AS\r\nSELECT\r\n\t-- This code was generated by ");
270270

271271
#line 3 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Date\VTimePointsToRanges.Oracle.sql"
272272
this.Write(this.ToStringHelper.ToStringWithCulture(TemplateName));
@@ -365,7 +365,7 @@ public virtual string TransformText()
365365
-- You must not remove this notice, or any other, from this software.
366366
--
367367
-- Original Author: Abel Cheng <[email protected]>
368-
-- Created Date: May 20, 2013, ‏‎12:00:44 AM
368+
-- Created Date: May 20, 2013, 12:00:44 AM
369369
-- Primary Host: http://t4sql.codeplex.com
370370
-- Change Log:
371371
-- Author Date Comment

T4SQLTemplateLibrary/T4Templates/Date/VTimePointsToRanges.partial.cs

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,27 +45,7 @@ public TemplateSpec GetPropertiesSpec()
4545
public string RangeEndDateColumn { get { return this.GetPropertyValue("RangeEndDateColumn"); } }
4646
public bool IsEndDateNext { get { return this.GetPropertyValue("EndDateNext").IsTrueString(); } }
4747
public IEnumerable<string> KeyColumns { get { return Key_Columns.SplitColumns(); } }
48-
49-
public string DefaultEndDate
50-
{
51-
get
52-
{
53-
string defaultEndDate = this.GetPropertyValue("DefaultEndDate");
54-
55-
if (string.IsNullOrWhiteSpace(defaultEndDate))
56-
return string.Empty;
57-
else
58-
{
59-
Regex rgDate = new Regex(@"\s*'?(?<dt>\d{4}-\d{2}-\d{2})'?\s*");
60-
Match mc = rgDate.Match(defaultEndDate);
61-
62-
if (mc.Success)
63-
return string.Format(((DbmsPlatform == "Oracle") ? "TO_DATE('{0}', 'YYYY-MM-DD')" : "CAST('{0}' AS DATE)"), mc.Groups["dt"].Value);
64-
else
65-
return defaultEndDate;
66-
}
67-
}
68-
}
48+
public string DefaultEndDate { get { return this.GetPropertyValue("DefaultEndDate").ConstantDateExpr(DbmsPlatform); } }
6949

7050
public IEnumerable<string> SelectColumns
7151
{
Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,41 @@
11
CREATE OR REPLACE VIEW <#= ObjectView #> AS
22
SELECT
3-
-- This code was generated by <#= TemplateName #> @ <#= DateTime.Now.ToString() #>
4-
*
3+
-- This code was generated by <#= TemplateName #> @ <#= DateTime.Now.ToString() #>
4+
D.<#= DailyDateColumn #><#= SelectColumns.Select(c => "S." + c).InsertRight() #>
55
FROM
6-
<#= SourceView #>
6+
(
7+
SELECT
8+
<#= SelectColumns.InsertLeft() #>
9+
<#= SourceDateColumn #> AS START$DATE,
10+
LEAD(<#= SourceDateColumn #>, 1, TO_DATE('2999-12-31', 'YYYY-MM-DD')) OVER (PARTITION BY <#= Key_Columns #> ORDER BY <#= SourceDateColumn #>)
11+
AS EXPIRE$DATE
12+
FROM
13+
<#= SourceView #>
14+
) S,
15+
<#= DailyView #> D
16+
WHERE
17+
S.EXPIRE$DATE > D.<#= DailyDateColumn #>
18+
AND S.START$DATE <= D.<#= DailyDateColumn #>
719

820
WITH READ ONLY;
21+
22+
----------------------------------------------------------------------------------------------------
23+
--
24+
-- Copyright 2013 Abel Cheng
25+
-- This source code is subject to terms and conditions of the Apache License, Version 2.0.
26+
-- See http://www.apache.org/licenses/LICENSE-2.0.
27+
-- All other rights reserved.
28+
-- You must not remove this notice, or any other, from this software.
29+
--
30+
-- Original Author: Abel Cheng <[email protected]>
31+
-- Created Date: May 15, 2013, 11:25:04 PM
32+
-- Primary Host: http://t4sql.codeplex.com
33+
-- Change Log:
34+
-- Author Date Comment
35+
--
36+
--
37+
--
38+
--
39+
-- (Keep code clean)
40+
--
41+
----------------------------------------------------------------------------------------------------

T4SQLTemplateLibrary/T4Templates/Date/VTimePointsToSeries.SqlServer.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ GO
6969
-- You must not remove this notice, or any other, from this software.
7070
--
7171
-- Original Author: Abel Cheng <[email protected]>
72-
-- Created Date: May 15, 2013, ‏‎11:25:04 PM
72+
-- Created Date: May 15, 2013, 11:25:04 PM
7373
-- Primary Host: http://t4sql.codeplex.com
7474
-- Change Log:
7575
-- Author Date Comment

T4SQLTemplateLibrary/T4Templates/Date/VTimePointsToSeries.cs

Lines changed: 98 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ public virtual string TransformText()
266266
-- You must not remove this notice, or any other, from this software.
267267
--
268268
-- Original Author: Abel Cheng <[email protected]>
269-
-- Created Date: May 15, 2013, ‏‎11:25:04 PM
269+
-- Created Date: May 15, 2013, 11:25:04 PM
270270
-- Primary Host: http://t4sql.codeplex.com
271271
-- Change Log:
272272
-- Author Date Comment
@@ -296,7 +296,7 @@ public virtual string TransformText()
296296

297297
#line default
298298
#line hidden
299-
this.Write(" AS\r\nSELECT\r\n-- This code was generated by ");
299+
this.Write(" AS\r\nSELECT\r\n\t-- This code was generated by ");
300300

301301
#line 3 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Date\VTimePointsToSeries.Oracle.sql"
302302
this.Write(this.ToStringHelper.ToStringWithCulture(TemplateName));
@@ -310,14 +310,107 @@ public virtual string TransformText()
310310

311311
#line default
312312
#line hidden
313-
this.Write("\r\n\t*\r\nFROM\r\n\t");
313+
this.Write("\r\n\tD.");
314314

315-
#line 6 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Date\VTimePointsToSeries.Oracle.sql"
315+
#line 4 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Date\VTimePointsToSeries.Oracle.sql"
316+
this.Write(this.ToStringHelper.ToStringWithCulture(DailyDateColumn));
317+
318+
#line default
319+
#line hidden
320+
321+
#line 4 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Date\VTimePointsToSeries.Oracle.sql"
322+
this.Write(this.ToStringHelper.ToStringWithCulture(SelectColumns.Select(c => "S." + c).InsertRight()));
323+
324+
#line default
325+
#line hidden
326+
this.Write("\r\nFROM\r\n\t(\r\n\t\tSELECT\r\n\t\t\t");
327+
328+
#line 8 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Date\VTimePointsToSeries.Oracle.sql"
329+
this.Write(this.ToStringHelper.ToStringWithCulture(SelectColumns.InsertLeft()));
330+
331+
#line default
332+
#line hidden
333+
this.Write("\r\n\t\t\t");
334+
335+
#line 9 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Date\VTimePointsToSeries.Oracle.sql"
336+
this.Write(this.ToStringHelper.ToStringWithCulture(SourceDateColumn));
337+
338+
#line default
339+
#line hidden
340+
this.Write("\t\tAS START$DATE,\r\n\t\t\tLEAD(");
341+
342+
#line 10 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Date\VTimePointsToSeries.Oracle.sql"
343+
this.Write(this.ToStringHelper.ToStringWithCulture(SourceDateColumn));
344+
345+
#line default
346+
#line hidden
347+
this.Write(", 1, TO_DATE(\'2999-12-31\', \'YYYY-MM-DD\')) OVER (PARTITION BY ");
348+
349+
#line 10 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Date\VTimePointsToSeries.Oracle.sql"
350+
this.Write(this.ToStringHelper.ToStringWithCulture(Key_Columns));
351+
352+
#line default
353+
#line hidden
354+
this.Write(" ORDER BY ");
355+
356+
#line 10 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Date\VTimePointsToSeries.Oracle.sql"
357+
this.Write(this.ToStringHelper.ToStringWithCulture(SourceDateColumn));
358+
359+
#line default
360+
#line hidden
361+
this.Write(")\r\n\t\t\t\t\t\t\t\t\t\tAS EXPIRE$DATE\r\n\t\tFROM\r\n\t\t\t");
362+
363+
#line 13 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Date\VTimePointsToSeries.Oracle.sql"
316364
this.Write(this.ToStringHelper.ToStringWithCulture(SourceView));
317365

318366
#line default
319367
#line hidden
320-
this.Write("\r\n\r\nWITH READ ONLY;\r\n");
368+
this.Write("\r\n\t)\tS,\r\n\t");
369+
370+
#line 15 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Date\VTimePointsToSeries.Oracle.sql"
371+
this.Write(this.ToStringHelper.ToStringWithCulture(DailyView));
372+
373+
#line default
374+
#line hidden
375+
this.Write("\tD\r\nWHERE\r\n\t\tS.EXPIRE$DATE > D.");
376+
377+
#line 17 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Date\VTimePointsToSeries.Oracle.sql"
378+
this.Write(this.ToStringHelper.ToStringWithCulture(DailyDateColumn));
379+
380+
#line default
381+
#line hidden
382+
this.Write("\r\n\tAND S.START$DATE <= D.");
383+
384+
#line 18 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Date\VTimePointsToSeries.Oracle.sql"
385+
this.Write(this.ToStringHelper.ToStringWithCulture(DailyDateColumn));
386+
387+
#line default
388+
#line hidden
389+
this.Write(@"
390+
391+
WITH READ ONLY;
392+
393+
----------------------------------------------------------------------------------------------------
394+
--
395+
-- Copyright 2013 Abel Cheng
396+
-- This source code is subject to terms and conditions of the Apache License, Version 2.0.
397+
-- See http://www.apache.org/licenses/LICENSE-2.0.
398+
-- All other rights reserved.
399+
-- You must not remove this notice, or any other, from this software.
400+
--
401+
-- Original Author: Abel Cheng <[email protected]>
402+
-- Created Date: May 15, 2013, 11:25:04 PM
403+
-- Primary Host: http://t4sql.codeplex.com
404+
-- Change Log:
405+
-- Author Date Comment
406+
--
407+
--
408+
--
409+
--
410+
-- (Keep code clean)
411+
--
412+
----------------------------------------------------------------------------------------------------
413+
");
321414
this.Write("\r\n");
322415

323416
#line 15 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Date\VTimePointsToSeries.tt"

0 commit comments

Comments
 (0)