10.07.2015 Views

Programming Guide - Actian

Programming Guide - Actian

Programming Guide - Actian

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

How You Can Create a User ClassThe code position of the statement invoking the SendSuperclass method issignificant. If it is important for the parent class's method to manipulateattributes or data before running the subclass-specific operations, theSendSuperclass method must be invoked before the subclass's code. If theoperations performed by the parent's method are dependent on the operationsspecific to the subclass, the SendSuperclass method must be invoked after theoperations specified for the subclass's code.The following sections provide methods that exemplify both of these situations.Examples of Method: Hire MethodThe following sections describe the Hire method as it is defined for theEmployee class and the TempEmployee, PermanentEmployee, and Managersubclasses.Each of these methods handles error checking, which performs a rollback if thedatabase access fails. A failure at the bottom of the hierarchy causes rollbacksin every method previously invoked by the SendSuperclass method.Employee VersionNote: No commit statements are issued in these methods to allow for futureadditions to the user class hierarchy. Adding a new subclass whose methodincludes additional SQL statements as part of the same transaction would forcea revision of all superseded methods containing a commit statement.These methods assume that the programmer handles all commits. Forconsistency, the rollback statements could alternatively be handled byindividual programmers and removed from the method scripts.In this top-level version of the Hire method, the method script defines thefunctions described in the following steps. The attributes referenced in thisscript are set interactively by the user in a frame whose fields are mappeddirectly to the user class. The method script does the following:1. Declares a variable to store error status:method Hire() =declareerrstat = integer not null;enddeclare2. Checks the employee's hire date. If no date has been assigned, suppliesthe current date:if CurObject.HireDate = '' thenCurObject.HireDate = 'today';endif;Working with Classes 131

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!