Java Reference
In-Depth Information
To Delete a User Stock Holding
1. Enter lines 278 through 298 as shown in Figure 11-36 on page 737.
TextPad displays the delUserStocks() method (Figure 11-51). The method
checks if the stock is held by other users and, if not, calls the delStock()
method to delete the stock record.
delUserStocks()
method
delStock()
method
FIGURE 11-51
The final database actions needed are those that query the database and
return one or more fields from one or more records.
Obtaining Database Field Values
According to the requirements document, the program must be able to
return a stock description (name) for a given stock. As was illustrated earlier, this
involves running a query where the search condition matches a single primary
key value, which is done on lines 316 and 317. If a matching record is found, on
line 319 the desired field is obtained from the result set. Line 323 returns the
obtained value to the calling program. If no result was obtained, a null value, set
on line 314, is returned.
The step on the next page enters the code to obtain a single value from a
record in the database.
 
Search WWH ::




Custom Search