A database function is called (dbfunction_call) in the same way as a function. The database function is created by executing a CREATE FUNCTION statement.
<dbfunction_call> ::= <dbfunction_name> ( [<expression>,...] )
The current user must have the authorization to execute the database function (EXECUTE privilege).
The avgprice database function determines the average price for single rooms in hotels that are located within the specified zip code range. This function could be used as follows:
SELECT hno, avgprice(zip) avgprice FROM hotel WHERE hno < 100
HNO |
AVGPRICE |
10 |
135 |
20 |
70 |
30 |
45 |
40 |
87,5 |
50 |
105 |
60 |
120 |
70 |
115 |
80 |
87,5 |
90 |
90 |
See also:
SQL Tutorial: Database Functions