Q

Difference between function, procedure and trigger

What is the difference between a function, a procedure and a trigger? I know the basic differences, but I would like to know the answers based on the performance tuning aspect.

What is the difference between a function, a procedure and a trigger? I know the basic differences, but I would...

like to know the answers based on the performance tuning aspect (especially function and procedure, as in Oracle even procedures can return values using OUT).

The 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, e.g.:

 BEGIN my_procedure(); END;

or use the CALL statement instead of a PL/SQL block:

 CALL my_procedure();
This was last published in January 2006

Dig Deeper on Using Oracle PL-SQL

PRO+

Content

Find more PRO+ content and other member only offers, here.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide

SearchDataCenter

SearchContentManagement

SearchFinancialApplications

Close