It needs to be a set instead of an array, so change the brackets to {}
instead:
for castle in {'Windsor Castle', 'Neuschwanstein', 'Hohenzollern Castle'}
union (
insert Castle {
name := castle
}
);
It looks like this:
select (
for castle in {'Windsor Castle', 'Neuschwanstein', 'Hohenzollern Castle'}
union (
insert Castle {
name := castle
}
)
) { name };
Since strength
comes from abstract type Person
, you would need to overload it and give it a constraint. The Vampire
type would then look like this:
type Vampire extending Person {
multi slaves: MinorVampire;
overloaded strength: int16 {
constraint min_value(10)
}
}
You could give them each a last_appearance
using the to_local_date
function that we used a lot in this chapter:
update Person
set {
last_appearance := cal::to_local_date(1893, 9, 11),
};
Or you could just cast to a cal::local_date
from a string:
update Person
set {
last_appearance := <cal::local_date>'1893-09-11'
};
5. All the Person
characters that have an e
or an a
in their name have been brought back to life. How would you update to do this?
You can just update
by using like
on a set instead of a single letter:
update Person filter .name like {'%a%', '%e%'}
set {
last_appearance := {}
};
And if you wanted to display the results at the same time to make sure, it would look like this:
select (
update Person filter .name like {'%a%', '%e%'}
set {
last_appearance := {}
}
) {
name,
last_appearance
};