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 to find 3rd highest salary of an employee from the employee table in sql?

0 Answers  


What programs use sql?

0 Answers  


Can you create a table with Primary Key not as the clustered index.

2 Answers   CGI,


Why are indexes and views important to an organization?

0 Answers  


can we delete the trigger in a view? if yes why if not why?

5 Answers   Tech Mahindra,


What are the different types of sql commands?

0 Answers  


What is mdb stand for?

0 Answers  


How to retrieve a second highest salary from a table? Note:Suppose salaries are in duplicate values eg: Name Sal Malli 60000 Pandi 60000 Rudra 45000 Ravi 45000

10 Answers   Mind Tree, Polaris, Sonata,


discuss about myisam key cache. : Sql dba

0 Answers  


What is primary key secondary key alternate key candidate key?

0 Answers  


What are the types of subqueries?

0 Answers  


What makes a good primary key?

0 Answers  


Categories