Explain the difference between a FUNCTION, PROCEDURE and
PACKAGE.
Answers were Sorted based on User's Feedback
Answer / esakkiraja
One more diff between function and procedure
Functions can be used in sql query but procedure we can't
used in sql query
For eg:
tax is a function we can use like
select ename,tax(sal) from emp where ename='saki';
In this we can use.....
| Is This Answer Correct ? | 64 Yes | 6 No |
Answer / aleena
PROCEDURE:
cannot return a value
SYNTAX:
CREATE PROCEDURE procedure_name [argument datatype]
AS
BEGIN
sql statements
END;
/
FUNCTION:
returns a value
SYNTAX:
CREATE FUNCTION function_name [argument[IN] datatype]
RETURN datatype
AS
BEGIN
sql statements
END;
/
PACKAGES
Pakages are groups of functions,procedures,sql blocks
goruped together in a single unit.
there are two parts to creating a PACKAGE --1>CREATE
PACKAGE & 2> CREATE PACKAGE BODY
SYNTAX :
CREATE PACKAGE :
CREATE PACKAGE package_name
AS
FUNCTION function_name(datatype);
PROCEDURE procedure_name (datatype);
.......
.......(sql/plsql statements )
........
END;
CREATE PACKAGE BODY :
CREATE PACKAGE BODY packagebody_name
AS
FUNCTION function_name (datatype)
RETURN datatype
AS
.....
.....
.....
END function_name;
PROCEDURE procedure_name (datatype)
AS
......
.....
.....
END procedure_name
END PACKAGE;
| Is This Answer Correct ? | 46 Yes | 5 No |
Answer / suresh
Function must return one value
Procedure may or may not return one or more values.
Can call functions in Sql statements
we can't call a procedure in sql statements
Functions can not return images
procedure returns images
| Is This Answer Correct ? | 24 Yes | 1 No |
Answer / subhasish dutta
If no write (i.e. insert,delete,update,merge) operation is
made in a function then that function can be used sql
query. if only read operation (i.e. Select) is used in a
function, that can be called from sql query.
| Is This Answer Correct ? | 19 Yes | 2 No |
Answer / deepak
Note:- procedure may or may not return value.function must
return value
Procedure return one or more value & function return only
single value.
Pakages are groups of functions,procedures,sql blocks
goruped together in a single unit.
Package & packagebody are two different thngs. Variable
defined in packages are global & they can use in anywhere
in packagebody. Variable defined in packagebody have
limited scope. & they can used in defined limit only.
| Is This Answer Correct ? | 16 Yes | 1 No |
Answer / rashmipriya
procedure call is pl/sql statement by itself.
function call is part of an expression.
| Is This Answer Correct ? | 16 Yes | 3 No |
Answer / karunakar remala
Procedure and functions contains scope with in package
only..but coming to it contains scope out side of the
package also.i.e we can access package elements from out
side of the package also.
| Is This Answer Correct ? | 11 Yes | 3 No |
Answer / ezhumalai
A Procedure that performs an action.
A Function that computes a value.
We can call a Function in SELECT Statement.
We can't call a Procedure in SELECT Statement.
| Is This Answer Correct ? | 5 Yes | 3 No |
Answer / san
can access package elements from out
side of the package only if its declare in package specification
| Is This Answer Correct ? | 4 Yes | 2 No |
Answer / kalaiselvan.j
The Function will return a value where procedure wont.
| Is This Answer Correct ? | 13 Yes | 31 No |
What is db_recovery_file_dest in oracle? When do you need to set this value?
What is database schema?
How would you determine the time zone under which a database was operating?
What is index? How many types of indexes?
What is mrc and what is its use? : oracle accounts receivable
What view would you use to determine free space in a tablespace?
how to write customizations in po
How would you determine what sessions are connected and what resources they are waiting for?
what is different between inline query,subquery& corelated query?
In my table i'm having the duplicate records with sequence number and my requirement is when in new record is coming i want to delete existing old record(onlyone i.e maintaing the partial duplicate date )and add new record
1.In a table Gender is a column in that male and female are the two data.In a single statement i have to modify all male to female and all female to male vice versa. 2.In a single query i need the count of male data,count of female and total count
What is the Difference between the Person_Type_id column in the per_all_people_f and per_person_type_usages_f