What's the differences between stored procedures, functions and routines?

后端 未结 5 1329
礼貌的吻别
礼貌的吻别 2020-12-07 15:34

In MySQL database context, what is the difference among these 3 terms:

  • stored procedure
  • stored function
  • stored routine<
5条回答
  •  臣服心动
    2020-12-07 15:53

    PROCEDURES VS FUNCTIONS

    1.  PROCEDURES may or may not return a value but FUNCTION must return a value
    2.  PROCEDURES can have input/output parameter but FUNCTION only has input parameter.
    3.  We can call FUNCTION from PROCEDURES but cannot call PROCEDURES from a function. 
    4.  We cannot use PROCEDURES in SQL statement like SELECT, INSERT, UPDATE, DELETE, MERGE etc. but we can use them with FUNCTION.
    5.  We can use try-catch exception handling in PROCEDURES but we cannot do that in FUNCTION. 
    6.  We can use transaction in PROCEDURES but it is not possible in FUNCTION.
    

提交回复
热议问题