Although the BM syntax resembles the syntax of SQL, there are important differences between SQL and OCL. The main difference is that SQL statements work on complete tables. OCL expressions always take a single object as starting point. They work on what is visible from that object. A common mistake is using the OCL select operation in the same manner as a SQL select statement. There is an important difference between the two. An OCL select operation results in a proper subset of the collection to which it was applied. A SQL select statement does not result in a subset of the records in the table it is working on. In OCL terminology, it collects values that are visible from the records in the table. Assume, for the sake of the argument, that the R&L diagram in Figure C-1 represents a database schema. The following SQL statement would result in a list of dates: SELECT goodThru FROM CustomerCard WHERE valid = true The OCL equivalent of this SQL statement would be collect cc.goodThru using cc: CustomerCard from select cc: CustomerCard from allInstances of CustomerCard where cc.valid = true |