Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I wish to create a snapshot of my small data table every monday except on those days that fall on a holiday.
On a normal Monday I load data, but if it is a holiday I need to load on the Tuesday and if that is a holiday ..... etc. The data is stored in a SQL database as are the tables that define holidays.
Any ideas ?
Thanks in advance
Something like this:
Let HolidayToday = date('12/31/2009'); // should be a current date in the real script
let WorkToday = date('2/1/2009'); // should be a current date in the real script
Holidays:
load * inline [
Holiday
12/31/2009
1/1/2010
];
left join (Holidays)
load
Holiday
,date(Holiday) as HolidayDate
resident Holidays;
Condition:
load
'HolidayToday' as Today,
if(exists(HolidayDate, '$(HolidayToday)'), 0, 1) as LoadFlag
autogenerate 1;
load
'WorkToday' as Today,
if(exists(HolidayDate, '$(WorkToday)'), 0, 1) as LoadFlag
autogenerate 1;
// peek first record
let TheFlag = peek('LoadFlag', 0, Condition);
if TheFlag = 1 then
Data:
load * inline [
id,name
1,aaaaaaa
2,bbbbbb
3,ccccc
];
end if
In the start of the script put
Load Date,
from Holidays;
if exists(today(),Date) or weekday(today()) <> 'mon' or vFlagSkippedMonday <> 1 then
if exists(today(),Date) and weekday(today()) = 'mon' then
LET vFlagSkippedMonday = 1;
end if
exit script;
end if
Something like this:
Let HolidayToday = date('12/31/2009'); // should be a current date in the real script
let WorkToday = date('2/1/2009'); // should be a current date in the real script
Holidays:
load * inline [
Holiday
12/31/2009
1/1/2010
];
left join (Holidays)
load
Holiday
,date(Holiday) as HolidayDate
resident Holidays;
Condition:
load
'HolidayToday' as Today,
if(exists(HolidayDate, '$(HolidayToday)'), 0, 1) as LoadFlag
autogenerate 1;
load
'WorkToday' as Today,
if(exists(HolidayDate, '$(WorkToday)'), 0, 1) as LoadFlag
autogenerate 1;
// peek first record
let TheFlag = peek('LoadFlag', 0, Condition);
if TheFlag = 1 then
Data:
load * inline [
id,name
1,aaaaaaa
2,bbbbbb
3,ccccc
];
end if
Excellent Solution
Thank you - And very fast too !!!!