DEV Community

AntDB
AntDB

Posted on

AntDB-Oracle Compatibility Developer’s Manual P4–7

Call Function

Functions can be used wherever expressions can appear in SPL statements. We can call a function by specifying the name of the function and the parameters in parentheses after the name.

name [ (parameters) ]

name is the name of the function. parameters is the list of actual parameters.

Note: If there are no actual parameters, the function can be called with an empty parameter list, and the parentheses after the function cannot be omitted.

The following example shows how to call a function.

select simple_function();

  SIMPLE_FUNCTION  
-------------------
 That's All Folks!
(1 row)
Enter fullscreen mode Exit fullscreen mode

The function is usually called in the SQL statement shown below.

SELECT empno "EMPNO", ename "ENAME", sal "SAL", comm "COMM",
emp_comp(sal, comm) "YEARLY COMPENSATION" FROM emp;

 EMPNO | ENAME  | SAL  | COMM | YEARLY COMPENSATION 
-------+--------+------+------+----------------------
  7369 | SMITH  |  800 |      |               19200
  7499 | ALLEN  | 1600 |  300 |               45600
  7521 | WARD   | 1250 |  500 |               42000
  7566 | JONES  | 2975 |      |               71400
  7654 | MARTIN | 1250 | 1400 |               63600
  7698 | BLAKE  | 2850 |      |               68400
  7782 | CLARK  | 2450 |      |               58800
  7788 | SCOTT  | 3000 |      |               72000
  7839 | KING   | 5000 |      |              120000
  7844 | TURNER | 1500 |    0 |               36000
  7876 | ADAMS  | 1100 |      |               26400
  7900 | JAMES  |  950 |      |               22800
  7902 | FORD   | 3000 |      |               72000
  7934 | MILLER | 1300 |      |               31200
(14 rows)
Enter fullscreen mode Exit fullscreen mode

Top comments (0)