Skip to content

Commit 2b475d4

Browse files
committed
Preparing for Oracle T4SQL Templates
1 parent 1b429fd commit 2b475d4

File tree

10 files changed

+90
-9
lines changed

10 files changed

+90
-9
lines changed

T4SQLTemplateLibrary/ConsoleTest/App.Config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</configSections>
66
<connectionStrings>
77
<!--<add name="T4SQLDB" providerName="System.Data.SqlClient" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=T4SQLDB;Integrated Security=True"/>-->
8-
<add name="T4SQLDB" providerName="Oracle.ManagedDataAccess.Client" connectionString="Data Source=ORCL;User Id=/" />
8+
<add name="T4SQLDB" providerName="Oracle.ManagedDataAccess.Client" connectionString="Data Source=ORCL;User Id=T4SQL;Password=T4SQL#Pwd" />
99
</connectionStrings>
1010
<appSettings>
1111
<!--<add key="Engine_Package" value="T4SQL.ENGINE_" />-->

T4SQLTemplateLibrary/Databases/Oracle/T4SQLDB/Scripts/4-Packages/02-ENGINE.pck

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,15 @@ END ENGINE;
135135
CREATE OR REPLACE PACKAGE BODY T4SQL.ENGINE IS
136136

137137

138-
g_Polling_Interval NUMBER(3);
138+
g_Polling_Interval NUMBER;
139139

140140

141141
FUNCTION GET_POLL_INTERVAL
142142
RETURN NUMBER
143143
AS
144144
BEGIN
145145
IF g_Polling_Interval IS NULL THEN
146-
SELECT NUMBER_VALUE INTO g_Polling_Interval
146+
SELECT NUMBER_VALUE / 86400.0 INTO g_Polling_Interval
147147
FROM T4SQL.ENGINE_CONFIG
148148
WHERE ELEMENT_NAME = 'POLL_INTERVAL';
149149
END IF;
@@ -208,6 +208,8 @@ BEGIN
208208
ELSE
209209
outSwitch_To_Mode := 'Standby';
210210
END IF;
211+
ELSE
212+
outSwitch_To_Mode := 'Standby';
211213
END IF;
212214

213215
SERVICE_PING('N');

T4SQLTemplateLibrary/Databases/Oracle/T4SQLDB/Scripts/4-Packages/03-CMD.pck

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CREATE OR REPLACE PACKAGE T4SQL.CMD IS
1+
CREATE OR REPLACE PACKAGE T4SQL.CMD AUTHID CURRENT_USER IS
22

33
----------------------------------------------------------------------------------------------------
44
--
@@ -75,6 +75,7 @@ BEGIN
7575
END IF;
7676

7777
EXECUTE IMMEDIATE tSQL;
78+
COMMIT;
7879

7980
tSQL := 'SELECT START_BUILD, OBJECT_CODE, COMPILED_ERROR FROM ' || inWorkitem_Table || ' WHERE WORKITEM_NAME = :workitem_name';
8081

T4SQLTemplateLibrary/Databases/Oracle/Test/Scripts/2-InitData/1-CreateSampleWorkspace.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
-- Run as a user with execute permission on T4SQL.META package
2+
13
BEGIN
24
IF NOT T4SQL.META.EXISTS_TABLE('test.sample_workspace') AND NOT T4SQL.META.EXISTS_TABLE('test.sample_properties') THEN
35
T4SQL.META.CREATE_WORKSPACE('test.sample_workspace', 'test.sample_properties', 'Sample Workspace', 'test');

T4SQLTemplateLibrary/Databases/Oracle/Test/Scripts/2-InitData/2-GenerateTestData.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
-- Run in test schema
22

33
insert into test.date_time_points (date_, catalog_id, position_id, value_, other_col)
44
select

T4SQLTemplateLibrary/Databases/Oracle/Test/Scripts/2-InitData/3-SetupWorkitems.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
-- Run after your T4SQL Template Engine (either Windows Service or Console Test) has started.
2+
13
DECLARE
24
tExists PLS_INTEGER;
35
BEGIN
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
GRANT SELECT, INSERT ON TEST.SAMPLE_PROPERTIES TO T4SQL;
2+
GRANT SELECT, UPDATE ON TEST.SAMPLE_WORKSPACE TO T4SQL;

T4SQLTemplateLibrary/Databases/SqlServer/Schema Objects/Schemas/T4SQL/Programmability/Stored Procedures/T4SQL.ENGINE_STANDBY_PING.proc.sql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ AS
2323
SET @outSwitch_To_Mode = N'Primary';
2424
ELSE
2525
SET @outSwitch_To_Mode = N'Standby';
26-
END;
26+
END
27+
ELSE
28+
SET @outSwitch_To_Mode = N'Standby';
2729

2830
EXEC T4SQL.ENGINE_SERVICE_PING 0;
2931

T4SQLTemplateLibrary/T4Templates/Date/VTimePointsToRanges.Oracle.sql

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
CREATE OR REPLACE VIEW <#= ObjectView #> AS
22
SELECT
33
-- This code was generated by <#= TemplateName #> @ <#= DateTime.Now.ToString() #>
4-
*
4+
<#
5+
string tEndDateCol = IsEndDateNext ? DateColumn : string.Format("({0} - 1)", DateColumn);
6+
#>
7+
<#= SelectColumns.InsertLeft() #>
8+
<#= DateColumn #> AS <#= RangeStartDateColumn #>,
9+
LEAD(<#= tEndDateCol #>, 1<#= DefaultEndDate.IsNullString() ? "" : ", " + DefaultEndDate #>) OVER (PARTITION BY <#= Key_Columns #> ORDER BY <#= DateColumn #>)
10+
AS <#= RangeEndDateColumn #>
511
FROM
612
<#= SourceView #>
713

T4SQLTemplateLibrary/T4Templates/Date/VTimePointsToRanges.cs

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,74 @@ public virtual string TransformText()
280280

281281
#line default
282282
#line hidden
283-
this.Write("\r\n\t*\r\nFROM\r\n\t");
283+
this.Write("\r\n");
284+
285+
#line 4 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Date\VTimePointsToRanges.Oracle.sql"
286+
287+
string tEndDateCol = IsEndDateNext ? DateColumn : string.Format("({0} - 1)", DateColumn);
288+
289+
290+
#line default
291+
#line hidden
292+
this.Write("\t");
293+
294+
#line 7 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Date\VTimePointsToRanges.Oracle.sql"
295+
this.Write(this.ToStringHelper.ToStringWithCulture(SelectColumns.InsertLeft()));
296+
297+
#line default
298+
#line hidden
299+
this.Write("\r\n\t");
300+
301+
#line 8 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Date\VTimePointsToRanges.Oracle.sql"
302+
this.Write(this.ToStringHelper.ToStringWithCulture(DateColumn));
303+
304+
#line default
305+
#line hidden
306+
this.Write("\t\tAS ");
307+
308+
#line 8 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Date\VTimePointsToRanges.Oracle.sql"
309+
this.Write(this.ToStringHelper.ToStringWithCulture(RangeStartDateColumn));
310+
311+
#line default
312+
#line hidden
313+
this.Write(",\r\n\tLEAD(");
314+
315+
#line 9 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Date\VTimePointsToRanges.Oracle.sql"
316+
this.Write(this.ToStringHelper.ToStringWithCulture(tEndDateCol));
317+
318+
#line default
319+
#line hidden
320+
this.Write(", 1");
321+
322+
#line 9 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Date\VTimePointsToRanges.Oracle.sql"
323+
this.Write(this.ToStringHelper.ToStringWithCulture(DefaultEndDate.IsNullString() ? "" : ", " + DefaultEndDate));
324+
325+
#line default
326+
#line hidden
327+
this.Write(") OVER (PARTITION BY ");
328+
329+
#line 9 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Date\VTimePointsToRanges.Oracle.sql"
330+
this.Write(this.ToStringHelper.ToStringWithCulture(Key_Columns));
331+
332+
#line default
333+
#line hidden
334+
this.Write(" ORDER BY ");
335+
336+
#line 9 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Date\VTimePointsToRanges.Oracle.sql"
337+
this.Write(this.ToStringHelper.ToStringWithCulture(DateColumn));
338+
339+
#line default
340+
#line hidden
341+
this.Write(")\r\n\t\t\t\t\t\t\t\tAS ");
342+
343+
#line 10 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Date\VTimePointsToRanges.Oracle.sql"
344+
this.Write(this.ToStringHelper.ToStringWithCulture(RangeEndDateColumn));
345+
346+
#line default
347+
#line hidden
348+
this.Write("\r\nFROM\r\n\t");
284349

285-
#line 6 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Date\VTimePointsToRanges.Oracle.sql"
350+
#line 12 "E:\Projects\T4SQL\T4SQLTemplateLibrary\T4Templates\Date\VTimePointsToRanges.Oracle.sql"
286351
this.Write(this.ToStringHelper.ToStringWithCulture(SourceView));
287352

288353
#line default

0 commit comments

Comments
 (0)