The examples used in this chapter assume a SQL table called sales_emps with these columns:
name – the employee’s name
id – the employee’s identification number
state – the state in which the employee is located
sales – amount of the employee’s sales
jobcode – the employee’s job code
The table definition is:
create table sales_emps (name varchar(50), id char(5), state char(20), sales decimal (6,2), jobcode integer null)
he example class is SQLJExamples, and the methods are:
region() – maps a U.S. state code to a region number. The method does not use SQL.
correctStates() – performs a SQL update command to correct the spelling of state codes. Old and new spellings are specified by input parameters.
bestTwoEmps() – determines the top two employees by their sales records and returns those values as output parameters.
SQLJExamplesorderedEmps() – creates a SQL result set consisting of selected employee rows ordered by values in the sales column, and returns the result set to the client.
job() – returns a string value corresponding to an integer job code value.
See “SQLJExamples class” for the text of each method.