Oracle Application Developer Question:

Download Job Interview Questions and Answers PDF

Explain Can we give DML statements inside a function?

Oracle Application Developer Interview Question
Oracle Application Developer Interview Question

Answer:

YES YOU CAN USE DML(SELECT) WITHIN User defined function(UDF). BUT KEEP IN MIND THAT UDF CAN ONLY RETURN ONE SINGLE VALUE. BUT YOU CANT USE DDL(CREATE/ALTER/DROP) WITHIN UDF. TO DO THAT YOU HAVE TO USE SP(Stored Procedure).

DML EXAMPLE:
CREATE OR REPLACE Function IncomeLevel
( name_in IN varchar2 )
RETURN varchar2
IS
monthly_value number(6);
ILevel varchar2(20);
cursor c1 is
select monthly_income
from employees
where name = name_in;
BEGIN
open c1;
fetch c1 into monthly_value;
close c1;
IF monthly_value <= 4000 THEN
ILevel := 'Low Income';
ELSIF monthly_value > 4000 and monthly_value <= 7000 THEN
ILevel := 'Avg Income';
ELSIF monthly_value > 7000 and monthly_value <= 15000 THEN
ILevel := 'Moderate Income';
ELSE
ILevel := 'High Income';
END IF;
RETURN ILevel;
END;

Download Oracle Application Developer Interview Questions And Answers PDF

Previous QuestionNext Question
Suppose You need to save a certificate request in a file system directory by using Oracle Wallet
Manager. What would you do?
A. export the certificate request
B. use the File > Save As option
C. import the certificate request and save it
D. upload the certificate request to the Directory Service
What is the format of oracle table?