what is difference between procedure and function,
procedure and trigger?
Answers were Sorted based on User's Feedback
Answer / arup ratan banerjee
Procedure and Function
----------------------
1)Function return atleast one value
Procedure may or may not return value
2)Function can be a part of expression
Procedure can't be a part of exception
Procedure and Trigger
----------------------
Procedure need to be executed explicitly
Trigger gets automatically executed when insert update or
delete is fired on a table.
commit can be done in procedure
commit cannot be done in case of triggerrs except for
autonomous transactions
Is This Answer Correct ? | 47 Yes | 4 No |
Diff. B/W Procudure & Func......
(1) Proc. may or may not return value or more than one.
but func. must return a single value.
(2) We can call a func. in a select stmt. but func. should
only with IN parameter.
But we can't call a procedure inside a selct stmt.
because calling a procedure itself a PL/SQL block.
There is no too much diff. b/w proc. & func. but the thing
is that when we are looking to get back a single value we
should use func. in case of more than one then we should go
for proc.
Diff. b/w proc. & trigger..
(1) We have to call a proc. explicitly but trigger will
fire implicitly with assosiated event.
Is This Answer Correct ? | 21 Yes | 4 No |
Answer / ganesh ganjre
Diff. b/w proc. & trigger..
procedure can be called from trigger but trigger can't be
called from procedure.
Trigger(Implicitly)
Procedure(Explicitly)
Is This Answer Correct ? | 14 Yes | 1 No |
Difference between Procs & Triggers is;
We have control over the firing of Stored Proceudres,
but we don't have control over the firing of Database
Triggers.
Is This Answer Correct ? | 12 Yes | 3 No |
Answer / jagadesh
procedure can take parameters as argument's but triggers
cannot take parameters as arguments
Is This Answer Correct ? | 7 Yes | 2 No |
Answer / manish
PROCEDURE ARE NOTHING THEY R JUST STEPS OD DOING SOMETHING
PROGAMATICALLY...SO USE IT
Is This Answer Correct ? | 1 Yes | 1 No |
he major difference to keep in mind is that trigger code is hard-parsed every time the trigger runs. You should therefore code all of your trigger actions in stored procedures (preferably implemented in packages, per good programming practice), and limit the trigger body to a PL/SQL block that just invokes the procedure. Learn sql from https://www.youtube.com/watch?v=7Vtl2WggqOg
Is This Answer Correct ? | 0 Yes | 0 No |
functions and procedures:
1.Functions Returns a value, procedure not return a value.
2.parsed & compiled at runtime, Procedure stored as a
pseudo code in database ie. Compiled form.
3.Cannot effect the state of database,sp effect the state
of database using Commit etc..
4.mainly used to compute the values, sp used to process the
tasks.
5.It can be invoked from sql statement :eg:select, sp can
not invoked.
6.it is not accept more than one argument.sp accept more
than one argument.
Trigger and procedure:
1.It is run Automatically , sp run it manually.
2.With in a trigger u can call the sp, with in a sp u can
not call the trigger.
3.when u r creating the trigger u have to identify event
and action of your trigger. not possible in sp.
4.Trigger not pass the arguments but sp pass the arguments.
Is This Answer Correct ? | 1 Yes | 3 No |
what is try_catch block in procedure
How do you display "13th of November, 17 days left for month end" without hardcoding the date.
Does varchar need length?
What is diff between bulk collect and forall
What is the need of a partition key?
Which is faster joins or subqueries?
what is a constraint? Tell me about its various levels. : Sql dba
What is the difference between sql and mysql?
How can you select unique records from a table?
in oracle 10g sw after compiling procedure how to pass parameter values ,if we (v_empid out number)how to give empid after successful compilation program.This site exact suitable for 10g with respect to question & answer same format , im trying sql browser & sql command prompt using exec procedure name & respective parameters.
What is rename command in sql?
wtite down triggr not any entry on Sunday