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
SNO | SNAME | STATUS | CITY |
---|---|---|---|
S1 | Smith | 20 | London |
S2 | Jones | 10 | Paris |
S3 | Blake | 30 | Paris |
S5 | Adams | 30 | Athens |
SP
SNO | PNO | QTY |
---|---|---|
S1 | P1 | 300 |
S1 | P2 | 200 |
S1 | P3 | 400 |
S1 | P4 | 200 |
S1 | P5 | 100 |
S1 | P6 | 100 |
S2 | P1 | 300 |
S2 | P2 | 400 |
S3 | P2 | 200 |
And here's the view we defined earlier. Supplier `S4` has also been removed from here.
S20
SNO | SNAME | STATUS | CITY | PNO | QTY |
---|---|---|---|---|---|
S1 | Smith | 20 | London | P1 | 300 |
S1 | Smith | 20 | London | P2 | 200 |
S1 | Smith | 20 | London | P3 | 400 |
S1 | Smith | 20 | London | P4 | 200 |
S1 | Smith | 20 | London | P5 | 100 |
S1 | Smith | 20 | London | P6 | 100 |