Previous | Next | Contents | Index | Navigation | Glossary | Library |
2) Default statements (if any)
3) Input statement (if any)
4) Other statements
ALIAS varname1 AS varname2
where varname1 is the name of an existing database item or global value, and varname2 is a unique name not currently known to the system nor used previously in your formula.
Use the Alias statement to define another name, or alias, for existing variables in the system. You can declare aliases for database items and global values.
Alias statements must appear before any other statements in a formula.
DEFAULT FOR <varname> IS <constant>
where varname is an input value or database item, and constant is a constant value matching the data type of varname.
Use the Default statement to set a default value for an input value or database item. The formula uses the default value if the database item is empty or the input value is not provided when you run the formula.
You can use the Default statement with the 'WAS DEFAULTED' test to detect when a default value has been used. For example:
DEFAULT FOR hourly_rate IS 3.00
X = hours_worked * hourly_rate
IF hourly_rate WAS DEFAULTED
THEN
MESG = 'Warning: hourly rate defaulted'
This example sets a default of 3.00 for the database item hourly_rate. If hourly_rate is empty (NULL) in the database, the formula uses the default value of 3.00 and issues a warning message.
Attention: You must use the Default statement for database items that can be empty. The Database Items window includes a check box labelled Default Required. This check box is checked for database items that can be empty. The Database Items window appears when you click the Show Items button on the Formulas window.
INPUTS ARE varname1(data type)[, varname2 (data type)] ...
Use the Inputs statement to pass input values from an element into a formula.
For example,
INPUTS ARE bonus (number),
start_date (date)
You do not need to declare the type of number variables because this is the default data type. You can define up to 15 input values for an element.
The Inputs statement must appear before the other formula statements except:
For example, the formula below:
INPUTS ARE wage_rate,
hours_worked
wage = wage_rate * hours_worked
RETURN wage
is more efficient than the second formula:
wage = wage_wage_rate * wage_hours_worked
RETURN wage
varname = expression
For example:
rate = hourly_rate + 14
wage = hours_worked * rate
Oracle FastFormula evaluates the expression on the right hand side of the statement, and places its result in the variable you name in the left hand side. The left side of an Assignment statement must always be a local variable because a formula can only change the value of local variables.
There are two clauses in the If statement: the THEN and ELSE clauses.
IF [NOT] condition
[logical operator] [NOT] condition
THEN
statement [statement ..]
ELSE
statement [statement ..]
expression comparator expression
The values represented by each expression are compared together in the way described by the comparator. The two expressions must both return the same data type. There are eight comparators, and the way they work depends upon the data type of the values they are comparing.
Comparator | Symbols | Data Types | Meaning |
---|---|---|---|
Equals | = | All | The condition is true if both expressions have exactly the same value. For text, the case of the expression must be the same. So, for example, 'Smith' is not equal to 'SMITH'. |
Not Equal to | != <> >< | All | The condition is true if the result of the first expression does NOT have the same value as the result of the second expression. |
Greater than | > | All | The condition is true if the first expression is alphabetically after, or has a numerically greater value, or a later date than the second expression. |
Less than | < | All | The condition is true if the first expression is alphabetically before, or has a numerically smaller value, or an earlier date than the second expression. |
Greater than or equal to | >= => | All | The condition is true if either the greater than OR the equal to comparator returns a true result. |
Less than or equal to | <= =< | All | The condition is true if either the less than OR the equal to comparator returns a true result. |
Like | LIKE | Text | The condition is true if the two text expressions match according to the rules of the LIKE syntax. You can include Wildcards in the text to allow searching for text that matches a pattern, or words that begin with a certain sequence of letters. - percent sign (%) matches any number of characters in that position - underscore (_) matches a single character occurrence in that position. |
Not Like | NOT LIKE | Text | The condition is true if the two text expressions do NOT match according to the rules of the LIKE syntax. |
Table A - 4. |
DEFAULT FOR employee_middle_name IS ' '
IF employee_middle_name WAS DEFAULTED
THEN
/* special processing */
High_salary = 'N'
IF Salary > 20000
THEN Tax = Salary * .25
High_salary = 'Y'
To prevent this, use brackets as follows:
High_salary = 'N'
IF Salary > 20000
THEN
(
Tax = Salary * .25
High_salary = 'Y'
)
Example:
/* Formula: LONDON ALLOWANCE FORMULA */
INPUTS ARE this_months_extra (number)
London_allowance = (grade_pay/20 + this_months_extra)
RETURN London_allowance
Notice that you do not have to declare the data type of local variables in the Return statement (as the formula already knows the data type).
Oracle FastFormula stops executing the formula when it reaches the Return statement. Any statements after the Return statement are ignored.
Previous | Next | Contents | Index | Navigation | Glossary | Library |