Advanced

Multiple assignment

We can perform multiple assignments in a single statement. This allows us to set inter-dependent values, since any constraints are only checked after all the assignments in a statement. We can assign multiple values to multiple variables using , to separate the assignments.

For example, here we'll remove a supplier from S and also from SP. The integrity constraints will be checked only after both of the assignments are complete and so will be satisfied.

S := S - S[SNO="S4"], SP := SP - SP[SNO="S4"]
S
SNOSNAMESTATUSCITY
S1Smith20London
S2Jones10Paris
S3Blake30Paris
S5Adams30Athens
SP
SNOPNOQTY
S1P1300
S1P2200
S1P3400
S1P4200
S1P5100
S1P6100
S2P1300
S2P2400
S3P2200

And here's the view we defined earlier. Supplier `S4` has also been removed from here.

S20
SNOSNAMESTATUSCITYPNOQTY
S1Smith20LondonP1300
S1Smith20LondonP2200
S1Smith20LondonP3400
S1Smith20LondonP4200
S1Smith20LondonP5100
S1Smith20LondonP6100