2. Writing Scripts and Procedures : Procedures : Local Procedures : Example—Local Procedure
 
Share this page                  
Example—Local Procedure
This section provides an example of a procedure definition and a sample call to the procedure. Here is the procedure definition:
procedure addtax (tax=float8, price=float8) =
{
     return (price * tax);
}
The name of the sample procedure is addtax. It has two parameters, tax and price. The data types of each are float8. The caller passes information to the procedure using these parameters. When you call the procedure, it uses the parameter values it receives from the caller in its calculations and returns the result to the caller.
The following is a sample statement calling the addtax procedure:
tax = callproc addtax (tax = taxpercent,
      price = costfield);
The order in which the parameters are specified in the callproc statement need not match the order in which they appear in the procedure's heading. However, they must be identical in name to the parameters in the procedure definition. Here is a second call to the same procedure:
cost = currprice + addtax (tax = .1, price = currprice);