This example shows how to use parameter host variables and expands the previous example by adding another method which updates a numeric field on one record of the Employer table.
public interface Employer { public void setEmployerSize(EmployerKey empKey, LongWrapper newSize) throws AppException, InformationalException; public LongWrapper countEmployers() throws AppException; }
The following struct is required to contain the primary key for the employer:
public final class EmployerKey implements Serializable, DeepCloneable { /** * REFERENCE_NUMBER -> String */ public String employerNumber = ""; }
The SQL statement for this method is:
UPDATE Employer SET size = :2.longValue WHERE employerNumber = :employerNumber;
Note that since longValue is contained in the second parameter it is necessary to qualify it with 2.. Unqualified parameter references are assumed to reference the first parameter.
The SQL statement below qualifies both parameters and is equivalent to the one above:
UPDATE Employer SET size = :2.newSize.longValue WHERE employerNumber = :1.employerNumber;