Builtin

wrap

wrap(a, {attr_list}, wrap_name)

A relation operator. Adds a new nested tuple, named wrap_name, containing each attr in the attr list moved down from a.

Examples

wrap
wrap($S, {SNO, SNAME, CITY}, sups)
STATUSsups
10
CITY
Paris
SNAME
Jones
SNO
S2
20
CITY
London
SNAME
Smith
SNO
S1
20
CITY
London
SNAME
Clark
SNO
S4
30
CITY
Paris
SNAME
Blake
SNO
S3
30
CITY
Athens
SNAME
Adams
SNO
S5

wrap with inverted attr_list
wrap($S, ~{STATUS}, sups)
STATUSsups
10
CITY
Paris
SNAME
Jones
SNO
S2
20
CITY
London
SNAME
Smith
SNO
S1
20
CITY
London
SNAME
Clark
SNO
S4
30
CITY
Paris
SNAME
Blake
SNO
S3
30
CITY
Athens
SNAME
Adams
SNO
S5

Note: this version gives the same results as above but behaves as expected if new attributes are added to the relation (and perhaps reads more easily).