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 does the hierarchical profiler does?
Difference between global and parameter variables?
What is the difference between a subquery and a join?
Why you are not able to create a table using select command,if it is having a LONG column? for eg:create table test as select * from test1 here test1 containg a column having LONG datatype...
How you will create Toad Function?
What is the difference between SQL table and the PLSQL table?
suppose we have a table in which 200 rows. i want to find 101 row ? what the query.... and how we find 4th and 5th highest salary and 1 to 10 highest salary
How can we solve sql error: ora-00904: invalid identifier?
how to get a list of all tables in a database? : Sql dba
i have a table with column sno with 30 records. i want to update this column by item by item in asp.net. i wantto enter new values into that from 1 to 30 how is it possible with backend c#
What is dynamic query?
what is the functionality of the function htmlentities? : Sql dba