GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  Database  >  Stored Procedures
Go To First  |  Previous Question  |  Next Question 
 Stored Procedures  |  Question 9 of 12    Print  
Why the stored functions can not be called from DML Statements? Why cant we modify the database by function?

  
Total Answers and Comments: 3 Last Update: May 26, 2008     Asked by: Appu 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
September 02, 2007 18:03:02   #1  
Vaibhav Doshi        

RE: Why the stored functions can not be called from DM...
While Creating the stored functions, It check the Purity Level ( WNDS, RNDS , WNPS , RNPS ). so functions can not modify any database by using DML.
 
Is this answer useful? Yes | No
March 10, 2008 03:42:52   #2  
sampra Member Since: February 2008   Contribution: 279    

RE: Why the stored functions can not be called from DML Statements? Why cant we modify the database by function?
give me sme simple answer
 
Is this answer useful? Yes | No
May 26, 2008 00:55:38   #3  
krishnaindia2007 Member Since: September 2007   Contribution: 870    

RE: Why the stored functions can not be called from DML Statements? Why cant we modify the database by function?
>>Why the stored functions can not be called from DML Statements? 
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.

>>Why cant we modify the database by function

The main purpose of a function is to compute a value. Generally we use procedures to make modifications in database. If you want you can do modifications using functions also. But you can't call such functions from DML statements.



 

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
Sponsored Links

 




About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape