压缩空气re the Difference Between Similar Terms

Difference Between

Home / Technology / IT / 编程 /Difference Between Procedures and Functions in Programming

Difference Between Procedures and Functions in Programming

January 26, 2011Posted byOlivia

Procedures vs Functions in Programming

Procedures and Functions in programming, allow programmers to group instructions together in a single block and it can be called from various places within the program. The code becomes easier to understand and more compact. By performing the modifications in a single place, the whole code will get affected. With the help of functions and procedures; a linear and long code can be divided into independent sections. They provide more flexibility to the coding of various programming languages and databases.

What are functions?

Functions are capable of accepting parameters which are also known as arguments. They carry out the tasks according to these arguments or parameters and return values of given types. We can explain it better with the help of an example: A function accepts a string as a parameter and returns the first entry or record from a database. It takes into account the content for a specific field that begins with such characters.

The syntax of function is as follows:

CREATE OR REPLACE FUNCTION my_func

(p_name IN VARCHAR2 := ‘Jack’) return varchar2 as begin … end

程序是什么?

Procedures can accept the parameters or arguments and they carry out tasks as per these parameters. If a procedure accepts a string as a parameter and it gives out a list with records in database for which content of a specific field begin with such characters.

The syntax of procedures is as follows:

CREATE OR REPLACE PROCEDURE my_proc

(p_name IN VARCHAR2 := ‘Jack’) as begin … end

Mainly, there are two ways by which a parameter is passed in functions and procedures; by value or by reference. If parameter is passed by a value; the modification is affected within the function or procedure without affecting the actual value of it.

On the other hand, if the parameters are passed by references; the actual value of this parameter will be changed wherever it is called within the code as per the instructions.

Difference between procedures and functions

• When the parameter is passed into the procedure; it does not return any value whereas a function always returns a value.

• One of the major differences in both of them is that procedures are not used in databases whereas functions play an important role in returning values from a database.

• Procedures are capable of returning multiple values and the functions are able to return limited values.

• DML operations can be used in stored procedures; however, they are not possible in functions.

• Functions can return only one value and it is mandatory whereas procedures can return n or zero values.

• In functions, error handling cannot be done whereas it can be performed in stored procedures.

• Input and output parameters can be passed in procedures whereas in case of functions; only input parameters can be passed.

• Functions can be called from procedures whereas it is not possible to call a procedure from a function.

• Transaction management can be considered in procedures and it cannot be considered in case of functions.

Related posts:

Difference Between Java and C language Difference Between C and C++ 对象和类的区别 Difference Between Java and JavaScript Difference Between Graph and Tree

Filed Under:编程Tagged With:arguments,C,Function,function call,functions in programming,Java,linear code,long code,no procedural,Oracle,parameter passing,parameters,程序调用,Procedure,procedure call,procedures in programming,编程languages,transaction management

About the Author:Olivia

Olivia is a Graduate in Electronic Engineering with HR, Training & Development background and has over 15 years of field experience.

Comments

  1. SourDovesays

    November 4, 2015 at 2:17 am

    When you type, “When the parameter is passed into the procedure; it does not return any value whereas a function always returns a value,” do you mean the parameter does not return a value, or do you mean the procedure does not? It seems to mean the procedure because you are comparing procedures to functions, which may return a value, and because a parameter can’t return anything.

    In that case, this statement, “Procedures are capable of returning multiple values,” and this one, “Functions can return only one value and it is mandatory whereas procedures can return n or zero values” appear to contradict the first.

    Also, I use plenty of functions that return no value.

    Reply

Leave a ReplyCancel reply

Your email address will not be published.Required fields are marked*

Request Article

Featured Posts

Difference Between Coronavirus and Cold Symptoms

Difference Between Coronavirus and Cold Symptoms

Difference Between Coronavirus and SARS

Difference Between Coronavirus and SARS

Difference Between Coronavirus and Influenza

Difference Between Coronavirus and Influenza

Difference Between Coronavirus and Covid 19

Difference Between Coronavirus and Covid 19

You May Like

Difference Between BPA and BPS

Difference Between BPA and BPS

Difference Between Mountain and Plateau

Difference Between Road and Street

Difference Between Road and Street

Difference Between Lake and Sea

Difference Between Lake and Sea

Difference Between POP and IMAP email Protocols

Latest Posts

  • What is the Difference Between Argumentative and Expository Essay
  • What is the Difference Between Benzophenone-3 and Benzophenone-4
  • What is the Difference Between Lymphokines and Cytokines
  • What is the Difference Between Gastrolyte and Hydralyte
  • What is the Difference Between Avobenzone and Benzene
  • What is the Difference Between Tight Junction and Adherens Junction
  • Home
  • Vacancies
  • About
  • Request Article
  • Contact Us

Copyright © 2010-2018Difference Between. All rights reserved.Terms of Useand Privacy Policy:法律.