May 2017
Intermediate to advanced
442 pages
11h 55m
English
It is very common to use an Enum to define the status of a record, and we will cover state machines in Chapter 15, State Machines. When defining an Enum for status, we will order the elements so that we can compare them in code.
In the case of the SalesStatus Enum, the elements are as follows:
|
Symbol |
Value |
|
None |
0 |
|
Backorder |
1 |
|
Delivered |
2 |
|
Invoiced |
3 |
|
Canceled |
4 |
This way, we can select all sales orders, which are not yet invoiced, using the following code lines:
select SalesId, SalesName from salesTable where salesTable.SalesStatus < SalesStatus::Invoiced
Sometimes, we will need to reverse the order. In the case of the InvenTrans table, there are two status fields: ...
Read now
Unlock full access