Was this helpful?
RANGE Examples
The following examples provide details.
The first three examples illustrate a common error: disjoint queries, which are queries that incorrectly mix declared and implicit range variables.
Example 1:
This example inadvertently deletes all rows in the "dept" table, not just the rows where the "dno" value is 1, because "d" and "dept" refer to different copies of the same table:
Wrong:
range of d is dept
delete d where dept.dno=1
Example 2:
The following example inadvertently returns the Cartesian product of the two tables, not just the "ename" and "dept" values from each row:
Wrong:
range of e is emp
retrieve (e.ename, emp.dept)
Example 3:
The following example inadvertently replaces the age value for all rows, not only for the "jones" rows:
Wrong:
range of e is emp
replace emp (e.age=e.age+1) where e.ename = "jones*"
Example 4:
This example correctly declares range variable "e" to range over the "employee" table and "d" over the "dept" table:
Right:
range of e is employee, d is dept
Last modified date: 06/10/2024