What is the Difference between Procedure and Function.Can we
call a Function in a DML?
Answers were Sorted based on User's Feedback
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 |
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 |
what is bdb (berkeleydb)? : Sql dba
what are %TYPE and %ROWTYPE? what is the difference?
7 Answers ICICI, Saama Tech, Sail,
is it possible to pass an object or table to a procedure as an argument?
Do we need to create index on primary key?
Is progress software supports to ( pl/sql )?
How to run sql statements through the web interface?
what happens if you no create privilege in a database? : Sql dba
How is indexing done in search engines?
What is varchar example?
Why is %isopen always false for an implicit cursor?
how to analyze tables with 'mysqlcheck'? : Sql dba
What are the syntax and use of the coalesce function?