What is difference between function and procedure?

Answer Posted / santosh(ssit)

Both functions and procedures can return values. Apart from
this following are the differences

1) Functions are used for computations where as procedures
can be used for performing business logic

2) Functions MUST return a value, procedures need not be.

3) You can have DML(insert,update, delete) statements in a
function. But, you cannot call such a function in a SQL query..
eg: suppose, if u have a function that is updating a table..
you can't call that function in any sql query.
- select myFunction(field) from sometable; will throw error.

4) Function parameters are always IN, no OUT is possible

5) Function returns 1 value only. procedure can return
multiple values(max. 1024)

6) Stored Procedure :supports deffered name resoultion
Example while writing a stored procedure that uses table
named tabl1 and tabl2 etc..but actually not exists in
database is allowed only in during creation but runtime
throws error Function wont support deffered name resolution.
Stored procedure returns always integer value by default
zero. where as function return type could be
scalar or table or table values(SQL Server).
Stored procedure is pre compiled exuction plan where as
functions are not.

7) A procedure may modifiy an object where a function can
only return a value.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

can i change the runtime properties of an object ? How can i check if a parameter exists in database ?

1407


what are the utilities and drivers

1834


What is the meaning Work bench?

1756


What is object repository in qtp?

552


Analyzing the checpoint results?

595






Does QTP have any limitations?Can it work with all kinds of programming languages like java,springs,ajax ,hybernet?Also does it work well with windows 7.What are its other limitations

1753


How to Upgrade or support firefox 2.0 version on QTP 9.0? I have installed QTP 9.0 and installed firefox 2.0. But in REcord and Run Settings, it shows firefox 1.5 in Web tab for browser selection.

1779


How many types of recording modes in qtp? Which will be used when?

542


What are the different types of recovery operation?

545


Want to verify notepad reports using QTP framework or any other BV script method. Can anyone share the method to achieve it? Eg. Person Name is the header and the actual name is John then how can we verify weather person name is John

2160


If you giving priority as p0, as a developer if I give priority as p2, What happens In user defined function ?

576


How many number of actions possible in qtp?

598


diff between qtp versions from 8.5

1559


How many tabs are available to view your test in a test pane and what are they?

557


Where to use function or action?

664