What are main difference between Stored Procedure and
Functions.

Answers were Sorted based on User's Feedback



What are main difference between Stored Procedure and Functions...

Answer / guru

stored procedure : It is Pre Compiled Code(PCode) it is stored
in Database. we can reuse without compile.

Function: It need compile whenever it will run.

Is This Answer Correct ?    15 Yes 4 No

What are main difference between Stored Procedure and Functions...

Answer / s. elaiyaraja

The Main difference between stored procedure and Function
is SP's can return the value or not, but Functions should
return the value.

And We can use the function within the Queries, but sp's we
won't able to use it in the queries.

We can implicitely execute the sp's. But function's we
can't.

Is This Answer Correct ?    11 Yes 1 No

What are main difference between Stored Procedure and Functions...

Answer / abapdeveloper09

Adding to S. Elaiyaraja's responnse:
- Functions should have RETURN clause

Is This Answer Correct ?    3 Yes 1 No

What are main difference between Stored Procedure and Functions...

Answer / hemanth

1) functions are used for computations where as procedures
can be used for performing business logic

2) functions MUST return a value, procedures need not be.

3) you can have DML(insert, update, delete) statements in a
function. But, you cannot call such a function in a SQL query..
eg: suppose, if u have a function that is updating a table..
you can't call that function in any sql query.
- select myFunction(field) from sometable;
will throw error.
4)We can call a function from a procedure, but it is not
possible to call a procedure from a function

Is This Answer Correct ?    6 Yes 4 No

What are main difference between Stored Procedure and Functions...

Answer / abhirup roy

In The above answers all the major differences have been disclosed, with one wrong information.
We can call a procedure from a function and vice-versa (as long as the function and procedure has same/similar scope).
In order to defend my point I am posting one small code below for reference.
DECLARE
PROCEDURE my_proc;
FUNCTION my_func RETURN NUMBER IS
BEGIN
my_proc;
RETURN -003;
END my_func;

PROCEDURE my_proc IS
BEGIN
DBMS_OUTPUT.PUT_LINE('22');
END my_proc;

BEGIN -- main
DBMS_OUTPUT.PUT_LINE(my_func);
END;

-- IT WILL WORK FOR EVERY OCCURRENCE --

Is This Answer Correct ?    1 Yes 0 No

What are main difference between Stored Procedure and Functions...

Answer / preethi

another important difference between procedure and function
is inside procedure we can use DML statements but inside the
function only select can be used not delete and update.

Is This Answer Correct ?    4 Yes 4 No

Post New Answer

More Oracle General Interview Questions

What are the different types of record groups in oracle? Explain each of them

0 Answers  


After using set unused can we enable the column again to use? Please give me some answers....

1 Answers   Maveric,


I need to get the values of the previous quarter.how to do this?eg: if my cuurent month is may i need to get the datas of the month jan,feb,march.Can it be done in oracle.I tried with date function q but for the month jan its not retriving the previous quarter(oct-dec).how to solve this.plpz anyone help me?

2 Answers   Philips,


What are the differences between lov and list item?

0 Answers  


What is difference between a formal and an actual parameter?

1 Answers  






Tab A A B ------ 1 A 2 B 3 C Tab B A B ----- 4 D 5 E 6 F Generate the value into B table from A table. Only table A has the value. Write the SQL query to get B table value.

0 Answers   TCS,


What is an oracle user account?

0 Answers  


9)When information has to be stored w.r.t employees and their respective departments, which of the following is the Correct formulation of entries? A)Employee and department would together be represented as an entity. B)This is too less information to decide on entities. C)An employee would be one entity and a department would be another. D)Such a scenario cannot be modelled in RDBMS

2 Answers   Mind Tree,


How do I connect to oracle database?

0 Answers  


What are the differences between char and nchar in oracle?

0 Answers  


What is oracle datasource?

0 Answers  


What does `(+)` do in a where clause?

1 Answers  


Categories
  • Oracle General Interview Questions Oracle General (1789)
  • Oracle DBA (Database Administration) Interview Questions Oracle DBA (Database Administration) (261)
  • Oracle Call Interface (OCI) Interview Questions Oracle Call Interface (OCI) (10)
  • Oracle Architecture Interview Questions Oracle Architecture (90)
  • Oracle Security Interview Questions Oracle Security (38)
  • Oracle Forms Reports Interview Questions Oracle Forms Reports (510)
  • Oracle Data Integrator (ODI) Interview Questions Oracle Data Integrator (ODI) (120)
  • Oracle ETL Interview Questions Oracle ETL (15)
  • Oracle RAC Interview Questions Oracle RAC (93)
  • Oracle D2K Interview Questions Oracle D2K (72)
  • Oracle AllOther Interview Questions Oracle AllOther (241)