English 中文(简体)
存储程序与用户界定的职能之间的区别
原标题:Difference between stored procedures and user defined functions

谁能解释所储存的程序与用户界定的职能之间的具体区别,在何种情况下,每种功能都是有益的?

问题回答

这是始终铭记的:

  • Procedure can return zero or n values whereas function can return one value which is mandatory.
  • Procedures can have input/output parameters for it whereas functions can have only input parameters.
  • Procedure allows select as well as DML statement in it whereas function allows only select statement in it.
  • Functions can be called from procedure whereas procedures cannot be called from function.
  • Exception can be handled by try-catch block in a procedure whereas try-catch block cannot be used in a function.
  • We can go for transaction management in procedure whereas we can t go in function.
  • Procedures can not be utilized in a select statement whereas function can be embedded in a select statement.
  • UDF can be used in the SQL statements anywhere in the WHERE/HAVING/SELECT section where as Stored procedures cannot be.
  • UDFs that return tables can be treated as another rowset. This can be used in JOINs with other tables.
  • Inline UDF s can be though of as views that take parameters and can be used in JOINs and other Rowset operations.

Source http://www.codeproject.com/Tips/286539/Difference-between-stored-procedure-and-function

一项职能始终具有价值,并且可以而不是履行DML声明(INSERT/UPDATE/DELETE)。

储存的程序不能回馈价值——你需要使用深层参数——并且可以操作DML声明。

Advantage of Using a Function vs a Stored Procedure?


除上述比较外,它们也是平等的。 但是,根据比较,视你需要做些什么,你可能比你的职能更经常地使用储存的程序。

用户确定的职能很少,如债务管理和金融分析系统(DML)数据表等。

<><>Differences:

  1. 程序可以接受投入(违约)、产出和排外型参数。 职能只能接受投入类型参数。

  2. Procedures may or may not return a value or may return more than one value using the OUTPUT and/or INOUT parameters. A procedure may return upto 1024 values through OUTPUT and/or INOUT parameters. Function always returns only one value.

  3. 仓储程序回报总是以零违约值为单位。 功能回报类型可以是小数或表或表值。

  4. 储存的胎盘可以形成一个表,但不能再回表。 职能可生成、更新和删除表变量。 它可以回到一张桌子。

  5. 储存程序可通过使用插入、删除、更新和创建业务来影响数据库的状况。 职能不能影响数据库的状况,这意味着我们无法在数据库上插入、删除、更新和创建业务。

  6. 储存程序储存在数据库中,汇编成册。 职能仅限运行时间分配。

  7. 储存的假装可以独立使用外部关键词。 储存程序不能用于选定/地点/行为条款。 职能来自选定/地点/行为条款。 甚至我们可以加入两项职能。

  8. Normally stored procedure will be used for perform specific tasks. Functions will be used for computing value. Stored procedure allows getdate () or other non-deterministic functions can be allowed. Function won’t allow the non-deterministic functions like getdate().

  9. 在储存程序中,我们可以使用交易报表。 我们无法行使职能。

  10. 储存的程序可以做到所有债务管理和金融分析系统业务,如插入新记录、更新记录和删除现有记录。 这一职能使我们无法在储存程序中等数据库表格中开展债务管理和金融分析系统的业务。 它使我们只能做某些行动。 它将无法在现有的表格上填写DML。 但是,我们仍然只能在用户界定职能内的表格变量上进行债务管理和金融分析系统的运作。

  11. 可在储存程序中设立临时表格(分类)。 在职能方面是不可能的。

  12. 当 s语出现错误时,T-SQL将忽视SPROC的错误,并着手处理其余法典中的下一个说明。 在职能方面,T-SQL将停止执行下一次声明。

参考这一联系:

https://www.spritle.com/blogs/201103/03/differences-between-stored-procedures-and-user- Defin-Functions/





相关问题
what is wrong with this mysql code

$db_user="root"; $db_host="localhost"; $db_password="root"; $db_name = "fayer"; $conn = mysqli_connect($db_host,$db_user,$db_password,$db_name) or die ("couldn t connect to server"); // perform query ...

Users asking for denormalized database

I am in the early stages of developing a database-driven system and the largest part of the system revolves around an inheritance type of relationship. There is a parent entity with about 10 columns ...

Easiest way to deal with sample data in Java web apps?

I m writing a Java web app in my free time to learn more about development. I m using the Stripes framework and eventually intend to use hibernate and MySQL For the moment, whilst creating the pages ...

join across databases with nhibernate

I am trying to join two tables that reside in two different databases. Every time, I try to join I get the following error: An association from the table xxx refers to an unmapped class. If the ...

How can I know if such value exists in database? (ADO.NET)

For example, I have a table, and there is a column named Tags . I want to know if value programming exists in this column. How can I do this in ADO.NET? I did this: OleDbCommand cmd = new ...

Convert date to string upon saving a doctrine record

I m trying to migrate one of my PHP projects to Doctrine. I ve never used it before so there are a few things I don t understand. In my current code, I have a class similar to this: class ...

热门标签