Previous  Next          Contents  Index  Navigation  Glossary  Library

Writing Efficient Payroll Calculation Formulas

The following statements are true as general guidelines for typical payroll runs:

Formula Format

Use comments and white space freely when entering formulas. This makes the formulas easier to read and understand, and has no effect on performance or memory usage. Use indentation for the same reason, especially when you are using brackets to control the order of processing.

It is good practice to include the following information in a comment at the beginning of a formula:

Variable Names and Aliases

Use names that are brief yet meaningful to improve readability. Name length has no effect on performance or memory usage. Use Aliases if the names of database items or global values are long.

Input Statements

Use Input statements rather than database items whenever possible. This improves formula processing by as much as a factor of ten. It speeds up the running of your payroll by eliminating the need to access the database for the input values.

Inefficient:

	Salary = Salary_annual_salary / 12
	         RETURN Salary

Efficient:

	INPUTS ARE Annual_salary
	Salary = Annual_salary / 12
	         RETURN Salary

Date Literals

Use the TO_DATE function only when the operand is a variable.

Inefficient:

	Start_date = TO_DATE ( '12-JAN-1992' )

Efficient:

	Start_date = '12-JAN-1992' (date)

Single Expressions

Use a single expression in straightforward formulas where this does not lead to confusion.

Inefficient:

	Temp = Salary / Annualizing_factor
	Tax = Temp * 3 

Efficient:

	Tax = (Salary / Annualizing_factor) * 3

Database Items

Do not refer to database items until you need them. People sometimes list at the top of a formula all the database items the formula might need, thinking this helps Oracle FastFormula process more quickly. However, this in fact slows processing by causing unnecessary database calls.

Inefficient:

	S = Salary
	A = Age
	IF S < 20000 THEN
		IF A < 20 THEN
		Training_allowance = 30
	ELSE
		Training_allowance = 0

Efficient:

	IF Salary < 20000 THEN
		IF Age < 20 THEN
			Training_allowance = 30
		ELSE
			Training_allowance = 0

The first example always causes a database fetch for Age whereas the second only fetches Age if Salary is less than 20000.


         Previous  Next          Contents  Index  Navigation  Glossary  Library