What is the Difference between Procedure and Function.Can we
call a Function in a DML?

Answers were Sorted based on User's Feedback



What is the Difference between Procedure and Function.Can we call a Function in a DML?..

Answer / sharad kumar

1. Function must return a value like any other Programing
Language.
2.yes we can call function from a DML.Remember count(*),sum
etc...

Is This Answer Correct ?    13 Yes 4 No

What is the Difference between Procedure and Function.Can we call a Function in a DML?..

Answer / ankush

Function always return a value. procedure may or may be not.
IN a select statement function may be called but we should
execute the procedure.

We can call a stored function from dml statement.

Here is simple example


CREATE OR REPLACE FUNCTION TEST_1 RETURN NUMBER IS

BEGIN

RETURN(10);

END;


SELECT TEST_1 FROM DUAL;


update emp

set sal = sal+ sal*test_1();


To be called from an sql statement a function should follow
the following purity rules.
1) When called from a SELECT statement , the function
should not modify database objects.
2) When called from INSERT , UPDATE, DELETE statements ,
the function can not query or modify the tables that was
modified by the statement.
3)When called from SELECT , DELETE, UPDATE, INSERT
Statements , a function should not contain TCL, DDL
commands.

Is This Answer Correct ?    3 Yes 0 No

Post New Answer

More SQL PLSQL Interview Questions

how mysql optimizes distinct? : Sql dba

0 Answers  


How can we schedule the procedure to run automatically ?

3 Answers  


What is the meaning of disabling a trigger?

0 Answers  


How many types of triggers exist in pl/sql?

0 Answers  


Explian rowid, rownum?

0 Answers  


Compare SQL and PL/SQL.

3 Answers  


what are the differences between get and post methods in form submitting. Give the case where we can use get and we can use post methods? : Sql dba

0 Answers  


How to connect a sql*plus session to an oracle server?

0 Answers  


What are the types of triggers ?

26 Answers   Aspire, BirlaSoft, TCS,


What is an index? What are the types of indexes? How many clustered indexes can be created on a table?

0 Answers  


Use The Implicit cursor to Query The Department table information Where Deptno is 30.check,if no record was found then print "Record Was Not Found".Else Print Deptname And Ename.Dept table Have Dname Varchar2(20),Deptno Number,EnameVarchar2(20).Please Answer In 2 mins,with in Maximum 15 lines.

5 Answers   Wipro,


Is sqlexception checked or unchecked?

0 Answers  


Categories