Using `SELECT` to call a function

前端 未结 1 1536
终归单人心
终归单人心 2020-12-31 10:21

I occasionally encounter examples where SELECT...INTO...FROM DUAL is used to call a function - e.g.:

SELECT some_function INTO a_variable FROM D         


        
1条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-31 10:54

    This practice dates from before PLSQL and Oracle 7. As already mentioned assignment was possible (and of course Best Practice) in Oracle7.

    Before Oracle 7 there were two widely used Tools that needed the use of Select ... into var from dual;

    On the one hand there used to be an Oracle Tool called RPT, some kind of report generator. RPT could be used to create batch processes. It had two kinds of macros, that could be combined to achieve what we use PLSQL for today. My first Oracle job involved debugging PLSQL that was generated by a program that took RPT batches and converted them automatically to PLSQL. I threw away my only RPT handbook sometime shortly after 2000.

    On the other hand there was Oracle Forms 2.x and its Menu component. Context switching in Oracle Menu was often done with a Select ... from dual; I still remember how proud I was when I discovered that an untractable Bug was caused by a total of 6 records in table Dual.

    I am sorry to say that I can not proof any of this, but it is the time of year to think back to the old times and really fun to have the answer.

    0 讨论(0)
提交回复
热议问题