Skip to main content

Difference between procedure and function in oracle sql plsql interview question and answers for experienced and fresher

 "It is the most accepted and guaranteed question asked in plsql interview for fresher and experienced candidates."

INTRODUCTION:

Function is calculating the program result on the basis of the given input. It will be returning value or control to the code or calling program. Procedures are calculating or performing the tasks in particular way on the basis of the given inputs. It will be returning the control to the calling function or code, but it will not return any value. In SQL server and DBMS, procedure is termed as stored procedure. It saves their time in terms of reusability and maintainablity.Oracle procedure and function are called as subprograms which are stored in the database as database objects.

FUNCTION:

It can be defined as the set of various instructions received as input from the users for performing the certain tasks.It will return the value. It is used in calculation of the inputs and will provide outputs on the basis of given inputs. It can be pre-defined and user defined. It will perform the required tasks on the basis of the block of codes. It is also called as the named plsql blocks.

PROCEDURE:

It can be defined as the set of various instructions received as input from the users for performing the certain tasks. It will not return the value on the basis of given inputs specified. It is also called as sub-programs. It is the set of plsql commands which is stored in the database with the name as like function. It is used and executed in the anonymous block or with help of exec keyword. It is useful in performance management and optimization, security and database management. It is used in the repetitive tasks and help in automation work.




DIFFERENCE:



Function

Procedure

It will calculate the program result on the basis of the given input.

It will perform the certain tasks in the particular order on the basis of inputs given.

It does not provide the support to try catch blocks.

It provides support to the try catch blocks.

It can be called in the sql query.

It cannot be called in the sql query.

Select statements can have the function calls.

Select statements cannot have the procedure calls.

It can return the returning value or control to the code or calling function.

It can return the control but cannot  return value to the code or calling function.

DML statements are not used.

DML statements are used.

It must deal with expressions.

It must not deal with expressions.

It can be called using procedure.

It cannot be called using function.

Explict exception handling is used.

Explicit exception handling is not used.

Compilation occurs when it is called in the program.

Compilation occurs once and it can be repeatedly and don’t have to compile every single time.







































It is not possible to insert, update and delete the data.

It is possible to insert, update and delete the data as operation work recommended to be changes on the database or server as per time.

It is used in an expression.

It is not used in the expression.

 

It can accept the output parameters. It uses OUT parameter.        

It can accept the input parameters. It uses IN,OUT and INOUT parameter.

 

Temporary tables are not used in functions.

Temporary tables are used in the procedure.

Functions can be called from functions.

Procedures cannot be called from functions.

DML queries are not used.

DML queries are used.

Transaction are not managed in the function.

Transaction are managed in the procedure.

In the header part, return clause is not present.

In the header part, return clause is present.

 


Comments

Popular posts from this blog

Difference between union and union all in oracle sql plsql

"This is one of the most important questions that interviewer might be asking in an interview.Infyosis,Linked group,Kyndryl,Vodafone Idea,IBM and Mphasis etc" INTRODUCTION: It is said to be set operators which is used to combine, add or concatenate two or more result sets. It is used in the multiple select statements where to combine to produce the final desired results.In other words,multiple select statements of similar column name in same order and having same data type to produce the unified result.In MIS datalake,when you are adding the modules of GST reconciliation which is to be used in micros in Excel or VB script, union and union all set operator is preferred for eliminating duplicate records or keeping duplicate records as per business requirement. Column must be of the same datatype for these operations of one select statement with another select statements. Columns must be in the same order in this set operators in the multiple select statements. Same number of co

Difference between decode and case oracle sql plsql interview question and answer

" This is the most accepted question for PLSQL developer role.It has been asked in many interviews like Mphasis and Kyndryl. "  INTRODUCTION: Case was came after oracle database version 8.1.6 whereas decode was came before oracle database version 8.1.6 .Decode and case statements in an oracle work or acts like if then elsif conditional statements. if sal='2000000' then 'General Manager' elsif sal='3000000' then 'Senior Manager' elsif sal='1200000' then 'Manager' else 'Employee' end if; create table student_details(Student_RollNo Number,Student_Name Varchar2(20),student_marks Number,student_result varchar2(1)); insert into student_details values (100,'Rahul',90,'P'); insert into student_details values (101,'Rakesh',30,'F'); insert into student_details values (102,'Ram',60,'P'); insert into student_details values (103,'Rohan',10,'F'); insert into student_detai

Difference view and Materialized view in Oracle SQL PLSQL Interview Question and Answer.

 " This is excepted question in oracle interview. It is asked in oracle technical support,PLSQL developer, SQL Analyst and SQL developer. " INTRODUCTION: View and Materialized view are called as the database object or the named query. View is the virtual table which stores the select statement from the base table by execution of the sql query at the runtime. View Query is running for the view definition. In the case of the materialized view, the data from the base table is loaded in the temporary or physical memory location by which the materialized view gets refreshed and all the dependent tables on the materialized view are also get updated after refresh operation. Materialized views are used in lakhs lines of code. In the data lake, tables are dependent on the master table to get updated where more than lakhs line of codes, today every reporting is based on this, in that case materialized view are used and preferred on the master tables. An activity of materialized view wi