prompt This is an exmaple of using TimeSeries package for Oracle;
prompt Create any table privilege is needed for this example;

prompt Initializing ts package.

prompt Creating package...

@@tsPackage.sql

prompt Initializing...
begin
    ts.Init;
end;

prompt Creating series...;
begin
     ts.CreateSeries('electro1', 1, 'Electricity consumption.');
     ts.CreateSeries('electro1trend', 1, 'Electro1 trend'); 
     
     ts.CreateSeries('electro2', 1, 'Electro1 segment');
     ts.CreateSeries('electro2trend', 1, 'Electro2 trend');
     ts.CreateSeries('seasonal', 1, 'Seasonalcomponent for electro2');
     
     ts.CreateSeries('sugar', 1, 'Sugar consumption');
     ts.CreateSeries('sugartrend', 1, 'Sugar consumption trend');
end;     

prompt Inserting Data...

@@electro_series.sql
@@electro2.sql
@@electro2trend.sql
@@sugar_series.sql

prompt Calulating trend of electro1...

begin
   ts.MovingAverage('electro1', 12, 'electro1trend');
end;

prompt Caclulating seasonal component of electro2...

begin
   ts.Seasonal('electro2', 'electro2trend', 'seasonal');
end;


select value as "Electro1" from electro1;
select value as "Electro2" from electro2;
select value as "Electro1 Trend" from electro1trend;
select value as "Electro2 trend" from electro2trend;
select value as "Electro2 Seasonal" from seasonal;

prompt Calulating trend of sugar...
begin
    ts.MovingAverage('sugar', 12, 'sugartrend');
end;

select value as "Sugar trend" from sugartrend;