What is the equivalent of SQL Server APPLY in Oracle?

后端 未结 3 1207
囚心锁ツ
囚心锁ツ 2020-12-14 09:21

I am new to Oracle. Is there a builtin keyword does the same job of SQL Server APPLY?

3条回答
  •  猫巷女王i
    2020-12-14 09:49

    In Oracle we can use a pipelined function in the FROM clause by using the TABLE() function.

    SQL> select * from table( get_dept_emps (10) )
      2  /
    
    ENAME                                 SAL MGR
    ------------------------------ ---------- ---------------------
    BOEHMER                              2450 SCHNEIDER
    SCHNEIDER                            5000
    KISHORE                              1300 BOEHMER
    
    SQL>
    

    This can be treated like any other table, for instance, by joining to it:

    SQL> select t.*
      2         , e.empno
      3  from
      4     table( get_dept_emps (10) ) t
      5             join emp e
      6             on e.ename = t.ename
      7  /
    
    ENAME             SAL MGR             EMPNO
    ---------- ---------- ---------- ----------
    BOEHMER          2450 SCHNEIDER        7782
    SCHNEIDER        5000                  7839
    KISHORE          1300 BOEHMER          7934
    
    SQL>
    

提交回复
热议问题