-
Notifications
You must be signed in to change notification settings - Fork 32
/
DENORMALIZE_Ex.ecl
54 lines (42 loc) · 1.27 KB
/
DENORMALIZE_Ex.ecl
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
43
44
45
46
47
48
49
50
51
52
53
54
ParentRec := RECORD
INTEGER1 NameID;
STRING20 Name;
END;
ChildRec := RECORD
INTEGER1 NameID;
STRING20 Addr;
END;
NamesTable := DATASET([ {1,'Gavin'},
{2,'Liz'},
{3,'Richard'},
{4,'Bob'}],
ParentRec);
OUTPUT(NamesTable);
NormAddrs := DATASET([{1,'10 Malt Lane'},
{2,'10 Yamato Rd'},
{2,'3 The cottages'},
{4,'9 Merchiston'},
{4,'53 Collington Rd'},
{4,'24 Dayton Av'},
{4,'8 Brent Alley'}],
ChildRec);
OUTPUT(NormAddrs);
DenormedRec := RECORD
ParentRec;
DATASET(ChildRec) Children;
END;
DenormedRec ParentLoad(ParentRec Le) := TRANSFORM
SELF.Children := [];
SELF := Le;
END;
Ptbl := PROJECT(NamesTable,ParentLoad(LEFT));
OUTPUT(Ptbl,NAMED('ParentDataReady'));
Ptbl DeNormThem(Ptbl Le, NormAddrs Ri) := TRANSFORM
SELF.Children := Le.Children + Ri;
// SELF.Children := Ri;
SELF := Le;
END;
DeNormedRecs := DENORMALIZE(Ptbl, NormAddrs,
LEFT.NameID = RIGHT.NameID,
DeNormThem(LEFT,RIGHT));
OUTPUT(DeNormedRecs,NAMED('NestedChildDataset'));