-
Notifications
You must be signed in to change notification settings - Fork 2
/
3b-cleanbins.sql
42 lines (31 loc) · 1.01 KB
/
3b-cleanbins.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
\echo 'Running clean-up processes'
UPDATE allbins
SET rub_start=(regexp_matches(rub_sched,'(\d\d\d\d-\d\d-\d\d)'))[1]
WHERE rub_start IS NULL;
UPDATE allbins
SET rec_start=(regexp_matches(rec_sched,'(\d\d\d\d-\d\d-\d\d)'))[1]
WHERE rec_start IS NULL;
UPDATE allbins
SET grn_start=(regexp_matches(grn_sched,'(\d\d\d\d-\d\d-\d\d)'))[1]
WHERE grn_start IS NULL;
--,
--hw_start=(regexp_matches(hw_sched,'(\d\d\d\d-\d\d-\d\d)'))[1]
UPDATE allbins
SET rub_weeks=(regexp_matches(rub_sched,'\/P(\d)W'))[1]
WHERE rub_weeks IS NULL;
UPDATE allbins
SET rec_weeks=(regexp_matches(rec_sched,'\/P(\d)W'))[1]
WHERE rec_weeks IS NULL;
UPDATE allbins
SET grn_weeks=(regexp_matches(grn_sched,'\/P(\d)W'))[1]
WHERE grn_weeks IS NULL;
--hw_weeks=(regexp_matches(hw_sched,'\/P(\d)W'))[1]
UPDATE allbins
SET rub_day=trim(to_char(rub_start::date,'Day'))
WHERE rub_day IS NULL;
UPDATE allbins
SET rec_day=trim(to_char(rec_start::date,'Day'))
WHERE rec_day IS NULL;
UPDATE allbins
SET grn_day=trim(to_char(grn_start::date,'Day'))
WHERE grn_day IS NULL;