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

What are sql objects?

0 Answers  


Why is a primary key important?

0 Answers  


What is %type in sql?

0 Answers  


Why are indexes and views important to an organization?

0 Answers  


Dear All, Question for this Week Find out possible error(s) (either at compile time or at runtime) in the following PL/SQL block. State the reason(s) and correct the errors. Declare Cursor C1 is select ename, sal, comm from emp; Begin For i in C1 Loop If i.comm between 299 and 999 then Dbms_output.put_line(i.Ename || ‘ ** Good Commission’); Elsif i.comm > 999 then Dbms_output.put_line(i.Empno || ‘ ** Very Good Commission’); close C1; Else Dbms_output.put_line(i.Ename || ‘ ** ’ ||nvl(i.comm,‘O’)); End if; End Loop; End;

7 Answers   Accenture,






What is $$ in sql?

0 Answers  


how to delete an existing column in a table? : Sql dba

0 Answers  


What will be the output of this Query? select to_char(trunc(add_months(sysdate-3),mm),mm/dd/yyyy) from dual

6 Answers   Cap Gemini, TCS,


What are Global Temporary tables

3 Answers   IBM, TCS,


Why is %isopen always false for an implicit cursor?

0 Answers  


What company owns postgresql?

0 Answers  


Is it important to partition hard disk?

0 Answers  


Categories