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 ClassTo enhance performance by executing a single database operation when hiringmanagers, the PermanentEmployee class has a private BonusTemp attribute,which is null by default. Because this attribute is private, no value can besupplied by invoking this method on a permanent employee object.The following code is the entire Hire method for PermanentEmployee:method Hire() =declareerrstat = integer not null;enddeclarebeginerrstat = CurMethod.SendSuperclass();if errstat = 0 thenCurObject.NextReviewDate =CurObject.HireDate + '3 months';insert into permemp (emp_num,next_review_date,insurance_plan,bonus_rate)values (:CurObject.EmpNum,:CurObject.NextReviewDate,:CurObject.InsurancePlan,:CurObject.BonusTemp);errstat = CurMethod.DBSession.ErrorNumber;if errstat != 0 thenrollback;CurMethod.InfoPopup(messagetext ='Database insert failed with error ' +varchar(CurMethod.DBSession.ErrorNumber),message_type = MT_ERROR);endif;endif;return errstat;endManager VersionThe only difference between a manager and its PermanentEmployee superclassis that managers are given a bonus rate when hired. Therefore, the script forthe Hire method that is redefined for the Manager subclass is the simplest ofall the classes described.The following code is the entire Hire method script for Manager:method Hire() =declareerrstat = integer not null;enddeclarebeginCurObject.BonusTemp = CurObject.BonusRate;errstat = CurMethod.SendSuperclass();return errstat;end134 <strong>Programming</strong> <strong>Guide</strong>

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

Saved successfully!

Ooh no, something went wrong!