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 Class3. Generates an employee number by increasing the sequence value inv_highest_number:update v_highest_number set h_number = h_number+ 1 where tbl_name = 'emp'4. Selects the highest employee number into the EmpNum attribute for thecurrent employee:select h_number as :CurObject.EmpNum fromv_highest_numberwhere tbl_name = 'emp';5. Inserts a new row into both the emp and jobs tables and checks for errors:insert into emp (emp_num, emp_type, last_name,first_name, hire_date, term_date, term_reason)values (:CurObject.EmpNum, :CurObject.Type,:CurObject.LastName, :CurObject.FirstName,:CurObject.HireDate,:CurObject.TerminationDate,:CurObject.TerminationReason);if CurMethod.DBSession.ErrorNumber = 0 theninsert into jobs (emp_num, job_class, pay,start_date)values (:CurObject.EmpNum,:CurObject.CurrentClass,:CurObject.CurrentPay, :CurObject.HireDate);endif;if CurMethod.DBSession.ErrorNumber != 0 thenrollback;message 'Database error; unable to insertemployee record.';endif;return CurMethod.DBSession.ErrorNumber;endTempEmployee VersionBecause all temporary employees have a known termination date and astandard termination reason at the time of hire, the purpose of redefining themethod for this user class is to guarantee that these values are inserted intothe emp table. After gathering the first of these values and providing thesecond, this method invokes its parent's method by using the SendSuperclassmethod.The TempEmployee invokes this method after setting values for the two criticalattributes (TerminationDate and TerminationReason) so that the parent'sversion of the Hire method runs with real values for these attributes.The following 4GL code is the entire Hire method script for TempEmployee:method Hire() =declareerrstat = integer not null;enddeclare132 <strong>Programming</strong> <strong>Guide</strong>

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

Saved successfully!

Ooh no, something went wrong!