Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 30

 1.

Top 7 Oracle Corporation interview questions and answers In this

ebook you can ref: • Top 7 Oracle Corporation interview questions

with answers and; other useful job interview materials such as: •

Types of interview questions; • Oracle Corporation interview tips; • 75

common interview questions… Interview questions and answers Page

1 of 10

 2. Question 1: Why do you want to work for Oracle Corporation?

This is a very simple question, but in order to give a suitable answer

to the recruitment position, you must know how to answer. You need

to know about the company you are willing to work for and read their

job description. When you are asked this question, tell them that

working for Oracle Corporation will be a challenging and beneficial

experience to you. 1. Some ways of answering: Normally, a candidate

may answer in such ways as following: • I don’t know; • Because I like

the job and like other employees in the company; or • The job is quite

a challenge to you which will help improve your development. 2. Some

sample answers: • I have heard that Oracle Corporation is currently

the company with the best training & development policy. This is

really a good chance for me to develop my career. • Oracle

Corporation is the number one in ABC industry which I have long been

studying and aiming for. I hope with my ability and the opportunity to

work here, I will be able to make a breakthrough in ABC area. • This is

a new industry in XYZ region. I am researching on this industry and

aiming to be a leading specialist in the sector. Interview questions

and answers Page 2 of 10


 3. Therefore, I would like to have an opportunity to develop my career

as expected as this opportunity. Question 2: What do you know about

Oracle Corporation? This question is one reason to do some research

on the organization before the interview. Find out where they have

been and where they are going. What are the current issues and who

are the major players? Sample answers: 1. A good organization with

perfect management. I heard that in this organization i can gain

knowledge and good atmosphere. 2. If its for a good renowned

company then its better to go through the company website and know

what’s the company profile and what’s their achievements/successes

and branches & other details. 3. According to me this is one of the

best company. It has a good Environment, We feel good working in

companies, which has good growth in the IT Industries. This

Organization has all the qualities like good growth, good Environment,

maintaining a best level in the IT Industries, etc. Question 3: What are

your career goals? 1. The reasons of this question: Interview

questions and answers Page 3 of 10

 4. This question will test your ability and ambition to develop yourself

as well as the ability to plan for the future. 2. Levels of career goals: •

You are not sure about your goals, then answer: I’m rather busy with

my duties and goals of the Company; as a result, I haven’t focused

much on my long-term personal goals. • You have goals not or very

little relating to the current job: For example, you are applying for a

sales manager, but your career goal is to become the head of

marketing department in the next 5 years. • Current job oriented

career goals: For example, you are working as a sales manager, you
goal is to become the area sales manager in the next 2 years and in

the next 5 years, you will be the regional sales manager. Useful

source: list of 37 career goals

http://interviewquestionsaz.blogspot.com/2013/07/list-of-37-career-

goals- samples.html Question 4: What are your biggest strengths?

This question will help polishing your qualification to the

requirements of the employer. Steps to answer this question: a)

Identify which you are good at: Knowledge; Experience; Skills;

Abilities. b) Prepare a list of your strong points: Interview questions

and answers Page 4 of 10

 5. c) Review the recruitment requirements: You should review

carefully the recruitment requirements to know for sure which

requirements are the most important to the employer. d) Make a list

of your strong points in your resume/cover letter: List and describe

your strong points in your resume and cover letter orderly. You should

make descriptions to those points in your resume. e) Prepare

persuasive answers to the question of the employer about strong

points: You do not only state your strong points to the employer but

must also provide evidence for them by references or records

attached with your application form. Useful source: List of 20 job

strengths samples

http://interviewquestionsaz.blogspot.com/2013/07/20-job-strengths-

samples-for- your-job.html Question 5: How long would you expect to

work for Oracle Corporation if hired? Some tips for this question: • It

is not right to be specific; else you are giving them the impression

that you are not going to stay if hired. • Specifics here are not good.
Something like this should work: I’d like it to be a long time. Or As

long as we both feel I’m doing a good job. Sample answers Interview

questions and answers Page 5 of 10

 6. • I’d like it to be here a long time; as much as you permit me and

believe that I am doing a good job to remain in your company. • I

worked for my previous employer … years. That demonstrates my

loyalty. So, as long as the work is challenging, and I will have growth

and training potential, I will be happy to work here. • First of all I pity

you for hiring me, I will rob you blind, eat all the almonds and pee in

the punch bowl any chance I get. So the answer to your question is,

until you catch on. Question 6: Do you know anyone who works for

Oracle Corporation? Answer tips: Be aware of the policy on relatives

working for the organization. This can affect your answer even though

they asked about friends not relatives. Be careful to mention a friend

only if they have good records in the company. Other interview tips •

Determine trends that is happening in your industry and how to

face/solve them. • Attributes/traits/abilities related to this job and

how to get them. • Review job specs, job description in job ads for

this position and try to think how to prove your capabilities. •

Research the employer profile thoroughly, the aims of their

recruitment and what are your task/roles. Interview questions and

answers Page 6 of 10

 7. Question 7: Why should Oracle Corporation hire you? For one, the

interview question “give us reasons to hire you”, “why should we

employ you” or “what can you bring to our company” is something


that differentiates the best candidates from the other good

candidates. This question deals with your ability to sell yourself.

Think of yourself as the product. Why should the customer buy? I.

Tips to answer: 1. One of the best ways to answer this question is to

make a short list of all your advantages and create a paragraph that

would point out the positive aspects that you would bring to the new

job position. 2. One of the points that you can raise is the similarity of

the job profile you are aiming for at the company to the job profile you

enjoyed in your previous job. 3. You can also draw the interviewer’s

attention to your key skills and strengths, namely – quick learning,

excellent communication skills, etc. 4. In addition, your professional

ambitions should be made clear – the motivation and dedication that

you have for the profession and the opening position. II. Answer

samples 1. Weak answers: • “I am a hard worker.” — This is a really

trite answer — almost anyone can say he or she is a hard worker. •

“Because I need a job.” — This answer is about YOU — “they” want to

know what you can do for “them.” Interview questions and answers

Page 7 of 10

 8. • “I saw your ad and could do the job.” — This answers lacks

passion and purpose. 2. Stronger answers: • “Because I have what it

takes to fill the requirements of this job – solve customer problems

using my excellent customer service skills.” • “Because I have three

years experience working with customers in a very similar

environment.” • “Because I have the experience and expertise in the

area of customer support that is required in this position.” Interview

questions and answers Page 8 of 10


 9. Useful interview materials: Free ebook: 75 common interview

questions and answers http://interviewquestionsaz.blogspot.com/p/free-

ebook-75-interview-questions- and.html Top 10 interview secrets to win

every job interview

http://interviewquestionsaz.blogspot.com/2013/07/top-10-secrets-to-win-

every- job.html 13 types of interview questions and how to face them

http://interviewquestionsaz.blogspot.com/p/13-types-of-interview-

questions.html Top 12 common mistakes in job interviews

http://interviewquestionsaz.blogspot.com/2013/07/top-12-common-

mistakes-in- job-interviews.html Job interview checklist 40 points

http://interviewquestionsaz.blogspot.com/2013/07/job-interview-

checklist-40- points.html Top 3 interview thank you letter samples

http://interviewquestionsaz.blogspot.com/2013/07/top-3-interview-thank-

you- letter-samples.html Interview questions and answers Page 9 of 10

 10. Other job interview tips for Oracle Corporation: 1. Practice types

of job interview such as screening interview, phone interview, second

interview, situational interview, behavioral interview (competency

based), technical interview, group interview… 2. Send interview thank

you letter to employers after finishing the job interview: first

interview, follow-up interview, final interview. 3. If you want more

interview questions for entry-level, internship, freshers, experienced

candidates, you can ref free ebook: 75 interview questions and

answers. 4. Prepare list of questions in order to ask the employer

during job interview:

http://interviewquestionsaz.blogspot.com/2013/07/top-10-questions-to-
ask- employer-duting.html Interview questions and answers Page 10

of 10

What are the different types of reports?


 Tabular
 Master Detail Reports
 Form Reports
 Form Letter Reports
 Mailing Labels Reports
 Matrix Reports
What are Anchors in reports builder?
An anchor defines the actual position of an object. Anchors are used to determine the vertical and horizontal
positioning of a child object relative to its parent.
What are the different types of anchors in Reports?
A There are two types of anchors in Oracle Reports:
 Implicit (Creates when a report will run)
 Explicit (Anchors you create)
What are different types of report triggers also define their order of firing ?
There are five reports trigger with order:
1-Before Parameter Form
2-After Parameter Form
3-Before Report
4-Between Pages
5-After Report
Before Form Trigger:
It will Fires before the Run time Parameter Form that will displayed on screen. By using this trigger you can change
the value of the parameters.
After Form Trigger:
Fires after the Run time Parameter Form is displayed. From this trigger, you can access parameters and check their
values. This trigger can also be used to change parameter values or, if an error occurs, return to the Runtime
Parameter Form.
Before Report Trigger:
It will Fires before the report is executed but after queries are parsed and data is fetched.
Between Pages Trigger:
Fires before each page of the report is formatted, except the very first page. This trigger can be used for
customized page formatting. (Note : In the Previewer, this trigger only fires the first time that you go to a page. If
you subsequently return to the page, the trigger does not fire again.)
After Report Trigger:
Fires after you exit the Previewer, or after report output is sent to a specified destination, such as a file, a printer,
or an Oracle*Mail userid. This trigger can be used to clean up any initial processing that was done, such as deleting
tables. Note, however, that this trigger always fires, whether or not your report completed successfully.
Format Triggers :
Format Triggers are PL/SQL functions executed before the object is formatted. The trigger can be used to
dynamically change the formatting attributes of the object.
What are Placeholder Columns ?
A placeholder is a logical column for which you can conditionally set the datatype and value via PL/SQL or a user
exit. Placeholder columns are useful when you want to selectively populate a column with a value.
What are the different page layout sections in Oracle Reports ?
A report has three main sections:
1-Report header pages
2-Report body/margin pages
3-Report trailer pages
What are different types of parameters?
There are two types of parameters:
1-System Parameters
2-User defined (bind and lexical) parameters
What is the difference between Bind and Lexical parameter?
1-Bind parameters are used to replace a single value in SQL or PL/SQL, such as a character string, number, or date.
2-Lexical parameters are placeholders for text that you embed in a SELECT statement. Use Lexical reference when
you want the parameter to substitute multiple values at runtime. You can use lexical references to replace the
clauses appearing after SELECT, FROM, WHERE, GROUP BY, ORDER BY, HAVING, CONNECT BY, and START WITH.
Define different types of Matrix report ?
1-Single query
2-Multi query
3-Nested Query
4-Matrix Break
How can you print one record per page in the output?
You can set the maximum records per page property of the Repeating frame to
What is ‘page protect’ property in report builder?
Page protect property for an object indicates whether to try to keep the entire object and its contents on the same
logical page. Checking Page Protect means that if the contents of the object cannot fit on the current logical page,
the object and all of its contents will be moved to the next logical page.
What is the ‘Print Condition Type’ property?
‘Print Condition Type’ property specifies the frequency with which you want the object to appear in the report. The
Print Condition Type options indicate the logical page(s) on which the object should be triggered to print with regard
to the Print Condition Object.
What are the various values of the ‘Print Condition Type’ property in Reports ?
The various values are :
1-All:
All means the object and all of its contents will be printed on all logical pages of the Print Condition Object. The
object will be repeated on any overflow pages of the Print Condition Object and will be truncated at the logical page
boundary, if necessary.
2-All but First:
All but First means the object and all of its contents will be printed on all logical pages of the Print Condition Object
except the first logical page. The object will be formatted only on overflow pages of the Print Condition Object and
will be truncated at the logical page boundary, if necessary.
3-All but Last:
All but Last means the object and all of its contents will be printed on all logical pages of the Print Condition Object
except the last logical page. The object will be repeated on any overflow pages of the Print Condition Object except
the last one and will be truncated at the logical page boundary, if necessary.
4-Default:
Default means that Oracle Reports will use object positioning to set the Print Condition Type to either *First or *Last
for you.
5-First:
First means that the object and all of its contents will only be printed on the first logical page of the Print Condition
Object. The object will be formatted and will overflow to subsequent pages, if necessary.
6-Last:
Last means that the object and all of its contents will only be printed on the last logical page of the Print Condition
Object. The object will be formatted after the Print Condition Object and will overflow to subsequent pages, if
necessary.
What is the difference when Flex mode is mode “ON” & when it is “OFF”?
When we set flex mode is ON then reports automatically resizes the parent when the child is resized.
What is the difference when confine mode is “ON” and when it is “OFF”?
When we set confine mode is “ON” thenobject cannot be moved outside its parent in the report layout.
What is the minimum number of groups that is required in matrix report?
Four groups are required for a matrix reports.
What is the lock option in reports layout in oracle reports builder?
when we set lock option we cannot move the fields in the layout editor outside the frame. This is very useful for
maintaining the fields.
What are different types of column in reports?
There are 3 types of columns in the reports builder:
1-Placeholder Column
2-Formula Column
3-Summary Column
PL/SQL Demystified
The best way of learning something is by asking questions. That's why I've organized this hub in a
question-answer format.

The questions range from Basic to Advanced. I gave a concise answer too, only for quick reference and
revision. For detailed answer to each question, refer to any Oracle PL/SQL online documentation.

Some of these questions were actually asked in my Job Interviews in the US.

I have added some others which I found interesting. Very useful to know.

What is a cursor ? ( Basic)

- Name or handle to a private SQL area where Oracle parses and fetches query results.

How to control how many cursors are open ?(Intermediate)

- Set OPEN_CURSORS parameter in initialization parameters.

What is shared SQL ? (Intermediate)

-Oracle recognizes similar statements. The SQL area is used many times for similar statements.

What is Parsing ? (Intermediate)

- Syntax checking, privileges checking, allocating Private SQL Area.

What is the difference between anonymous blocks and stored procedures ? ( Basic)

- Anonymous block is compiled only when called.

- Stored procedure is compiled and stored in database with the dependency information as well.

- Former is PL/SQL code directly called from an application. Latter is stored in database.

- Former has declare statement.Latter doesnt.

What are the advantages of procedures ? ( Basic)

- Loaded once and used many times

- Performance better coz all SQL stmts are sent in one go from the application to the database

- Security ( no object privileges are given directly )

- Invoker's rights possible

- Data integrity, productivity


What are standalone procedures ? (Basic)

- Those that are not part of package

How is a PL/SQL program stored in database ? (Advanced)

- Parsed code is stored. It's called P-code

How is a PL/SQL program executed ?(Advanced)

- Prior to Oracle 9i, we have only bytecode and a virtual machine in the database runs it. Later versions
have faster native code execution.

- PL/SQL engine is the main component that executes procedural stmt and passes the SQL to the SQL
statement executor.

What are the advantages and disadvantages of DBMS_SQL ? (Intermediate)

- It has all the advantages of dynamic sql .. like runtime construction of sql, DDL statements can be
executed.

- Its advantage over EXECUTE IMMEDIATE is it can Describe objects

- It's kind of bulky and difficult compared to EXECUTE IMMEDIATE.

What is a package spec and package body ? Why the separation ? ( Basic)

- Spec declares public constructs. Body defines public constructs, additionally declares and defines Private
constructs

- Separation helps make development easier

- Dependency is simplified. You can modify body without invalidating dependent objects.

What are the advantages of Packages ? ( Basic)

- Encapsulation of code logic

- Privileges to objects can be controlled

- Loaded once into memory , used subsequently.

- Dependency simplified

- Public/private procs, functions, variables

How do you handle exceptions for bulk operations ? (Intermediate)

- Use the SAVE EXCEPTIONS clause ( FORALL index IN bound_clause SAVE EXCEPTIONS LOOP ...
END LOOP )

- Use 'Exceptions When Others' to handle the exceptions

- SQL%BULK_EXCEPTIONS(i).ERROR_CODE,

SQL%BULK_EXCEPTIONS(i).ERROR_INDEX
SQL%BULK_EXCEPTIONS.COUNT

Tell some tips to avoid performance problems in PL/SQL. (Intermediate to Advanced)

- Use FORALL instead of FOR, and use BULK COLLECT to avoid looping many times

- Tune SQL statements to avoid CPU overhead

- Use NOCOPY for OUT and IN OUT if the original value need not be retained. Overhead of keeping a copy
of OUT is avoided.

- Reorder conditional tests to put least expensive ones first

- Minimize datatype conversions => Assign data to exact same type variables

- Use PLS_INTEGER for computation intensive code. NUMBER, INTEGER maintain precision and scale
but not optimized for performance as additional checks are made to maintain precision and scale.

- Do not use subtypes like POSITIVE, NATURAL, INTEGER as they have additional checks

- Use BINARY_FLOAT, BINARY_DOUBLE

- EXECUTE IMMEDIATE is faster than DBMS_SQL

How to know PL/SQL compile parameters ?(Advanced)

- SHOW PARAMETERS PLSQL

- ALL_PLSQL_OBJECT_SETTINGS

What is MERGE ?( Basic)

- Combination of INSERT and UPDATE

Tell some new features in PL/SQL in 10g (Intermediate to Advanced)

- Regular expression functions REGEXP_LIKE , REGEXP_INSTR, REGEXP_REPLACE, and


REGEXP_SUBSTR

- Compile time warnings

- Conditional compilation

- Improvement to native compilation

- BINARY_INTEGER made similar to PLS_INTEGER

- INDICES OF , VALUES OF in FORALL lets you work on non-consecutive indices

- Quoting mechanism . Instead of quoting single quotes twice everytime, give your own delimiter to go on
using single quotes.

Ex: q'!I'm a string, you're a string.!'

- Flashback Query functions. SCN_TO_TIMESTAMP, TIMESTAMP_TO_SCN


- Implicit conversion between CLOB and NCLOB

- Improved Overloading

- New datatypes BINARY_FLOAT, BINARY_DOUBLE

- Global optimization enabled

- PLS_INTEGER range increased to 32bit

- DYNAMIC WRAP using DBMS_DDL

What is a sequence ? (Basic)

- A database object that offers high-speed access to an integer value

- Guaranteed to be unique (within that sequence).

-Used commonly to generate Primary key values


SQL and Pl/SQL Interview
Questions-1
Q.What is a stored procedure ?

A stored procedure is a sequence of statements that perform specific function.


A stored procedure is a named pl/sql block which performs an action.It is stored in the
database as a schema object and can be repeatedly executed.It can be invoked,
parameterised and nested.

Q.What is SQL*Loader?

SQL*Loader is a product for moving data in external files into tables in an Oracle
database. To load data from external files into an Oracle database, two types of input
must be provided to SQL*Loader : the data itself and the control file. The control file
describes the data to be loaded. It describes the Names and format of the data files,
Specifications for loading data and the Data to be loaded (optional). Invoking the loader
sqlload username/password controlfilename <options>.

Q.What are the two parts of a procedure ?

the above person have answerd wrong. Or rather the question may be wrong. It should
be packages instead of procedures. What are the 2 parts of package ? But the question is
what are the 2 parts for procedue!!!
Procedure Specification and Procedure Body.

Q.What is Date Functions?


Date Functions are ADD_MONTHS, LAST_DAY, NEXT_DAY, MONTHS_BETWEEN &
SYSDATE.

Q.What is NVL?
NVL: Null value function converts a null value to a non-null value for the purpose of
evaluating an expression. Numeric Functions accept numeric I/P & return numeric values.
They are MOD, SQRT, ROUND, TRUNC & POWER.

Q.What is Intersect?
Intersect is the product of two tables listing only the matching rows.

Q.How to know the last executed procedure?


Execute procedure name (parameter1,parameter2)
Select timestamps, owner, obj_name, action_name from dba_audit_trail;this statement
gives last executed time for procedure , function & package.

Q.What are the Restrictions on Cursor Variables?


Currently, cursor variables are subject to the following restrictions:You cannot declare
cursor variables in a package spec. For example, the following declaration is not
allowed:CREATE PACKAGE emp_stuff AS TYPE EmpCurTyp IS REF CURSOR RETURN emp
%ROWTYPE; emp_cv EmpCurTyp; -- not allowedEND emp_stuff;You cannot pass cursor
variables to a procedure that is called through a database link.If you pass a host cursor
variable to PL/SQL, you cannot fetch from it on the server side unless you also open it
there on the same server call.You cannot use comparison operators to test cursor
variables for equality, inequality, or nullity.You cannot assign nulls to a cursor
variable.Database columns cannot store the values of cursor variables. There is no
equivalent type to use in a CREATE TABLE statement.You cannot store cursor variables in
an associative array, nested table, or varray.Cursors and cursor variables are not
interoperable; that is, you cannot use one where the other is expected. For example, you
cannot
reference a cursor variable in a cursor FOR loop

Q.What is Minus?
Minus is the product of two tables listing only the non-matching rows.

Q.What are the cursor attributes used in PL/SQL?


% ISOPEN - To check whether cursor is open or not
% ROWCOUNT - Number of rows fetched/updated/deleted.
% FOUND - To check whether cursor has fetched any row. True if rows are fetched.
% NOT FOUND - To check whether cursor has fetched any row. True if no rows are
featched.
These attributes are proceeded with SQL for Implicit Cursors and with Cursor name for
Explicit Cursors.

Q.What is Consistency?
consistency: states that until commit the data will not be reflected to other users,in order
to maintain proper consistency.
consider a example: if user A transfer money to user B. The changes are updates in A
account (debit) but until it will be updated in B (credit) too till then others will not be able
to see the debit of A. when debit to A and credit to B happen then one can see the
updates hence maintain consistency

Q.What are % TYPE and % ROWTYPE? What are the advantages of using these
over data types?
% TYPE provides the data type of a variable or a database column to that variable.
% ROWTYPE provides the record type that represents a entire row of a table or view or
columns selected in the cursor.
The advantages are : I. Need not know about variable's data type
ii. If the database definition of a column in a table changes, the data type of a variable
changes accordingly.
Q.What will the Output for this Coding
Declare
Cursor c1 is select * from emp FORUPDATE;
Z c1%rowtype;
Begin
Open C1;
Fetch c1 into Z;
Commit;
Fetch c1 in to Z;
end;
By declaring this cursor we can update the table emp through z,means wo not need to
write table name for updation,it may be only by "z".
By issuing the TCL like commit or rollback, the cursor will be closed automatically, you
cannat fetch again. You will get an error if you

Q.What is Commit?
Commit is an event that attempts to make data in the database identical to the data in
the form. It involves writing or posting data to the database and committing data to the
database. Forms check the validity of the data in fields and records during a commit.
Validity check are uniqueness, consistency and db restrictions.

Q.Give the structure of the function?


FUNCTION name (argument list .....) Return datatype is
local variable declarations
Begin
executable statements
Exception
execution handlers
End;

Q.What is a cursor ? Why Cursor is required?


Cursor is a named private SQL area from where information can be accessed. Cursors are
required to process rows individually for queries returning multiple rows.

Q.If the application is running very slow? At what points you need to go about
the database in order to improve the performance?
For improving performance, we need to check the sql statement blocks , because for
every sql satement execution transfor to sql engine and come back to plsq engine that
process takes more time to process the plsql block.

Q.What are advantages fo Stored Procedures?


Extensibility,Modularity, Reusability, Maintainability and one time compilation.

Q.What is difference b/w stored procedures and application procedures, stored


function and application function?
Stored procedures are subprogrammes stored in the database and can be called
&executee multiple times wherein an application procedure is the one being used for a
particular application same is the way for function.
Both can be executed any number of times. Only difference is that stored procedures/
functions are stored in database in complied format while the application
procedures/functions are not in precomplied format and at run time has to be compiled.

Q.What is a cursor ? Why Cursor is required?


Cursor is a named private SQL area from where information can be accessed. Cursors are
required to process rows individually for queries returning multiple rows.

Q.State the difference between implicit and explicit cursor's.


Implicit Cursor are declared and used by the oracle internally. whereas the explicit
cursors are declared and used by the user. more over implicitly cursors are no need to
declare oracle creates and process and closes autometically. the explicit cursor should be
declared and closed by the user.

Q.How to avoid using cursors? What to use instead of cursor and in what cases
to do so?
just use subquery in for clause
ex:
for emprec in (select * from emp)
loop
dbms_output.put_line(emprec.empno);
end loop;
no exit statement needed
implicit open,fetch,close occurs

Q.What is pl/sql?what are the advantages of pl/sql?


PL/SQL(a product of Oracle) is the 'programming language' extension of sql.
It is a full-fledged language although it is specially designed for database centric
activities.

Q.How to disable multiple triggers of a table at at a time?


ALTER TABLE<TABLE NAME> DISABLE ALL TRIGGER

Q.How many types of database triggers can be specified on a table ? What are
they ?
Insert Update Delete
Before Row o.k. o.k. o.k.
After Row o.k. o.k. o.k.
Before Statement o.k. o.k. o.k.
After Statement o.k. o.k. o.k.
If FOR EACH ROW clause is specified, then the trigger for each Row affected by the
statement.
If WHEN clause is specified, the trigger fires according to the returned Boolean value.
Q.Explain how procedures and functions are called in a PL/SQL block ?
Function can be called from SQL query + explicitly as well
e.g 1)select empno,salary,fn_comm(salary)from employee;
2)commision=fn_comm(salary);
Procedure can be called from begin-end clause.
e.g.
Begin
(
proc_comm(salary);
)
end
Function is called as part of an expression.
sal := calculate_sal ('a822');
procedure is called as a PL/SQL statement
calculate_bonus ('A822');

Q.What will happen after commit statement ?


Cursor C1 is
Select empno,
ename from emp;
Begin
open C1; loop
Fetch C1 into
eno.ename;
Exit When
C1 %notfound;-----
commit;
end loop;
end;
The cursor having query as SELECT .... FOR UPDATE gets closed after
COMMIT/ROLLBACK.
The cursor having query as SELECT.... does not get closed even after
COMMIT/ROLLBACK.

Q.What happens if a procedure that updates a column of table X is called in a


database trigger of the same table ?
Trigger will be called... Based on the event what trigger as to do. if trigger is also doing
the same update statment then Mutating Table occurs. if trigger is not doing any DML
statment nothing happens just Trigger will be called..

Q.Can we declare a column having number data type and its scale is larger than
pricesion
ex: column_name NUMBER(10,100),
column_name NUMBAER(10,-84)
Yes,
we can declare a column with above condition.
table created successfully.

Q.The IN operator may be used if you know the exact value you want to return
for at least one of the columns.
SELECT column_name FROM table_name WHERE column_name IN (value1,value2,..)

Q.What is SQL Deadlock?


Deadlock is a unique situation in a multi user system that causes two or more users to
wait indefinitely for a locked resource. First user needs a resource locked by the second
user and the second user needs a resource locked by the first user. To avoid dead locks,
avoid using exclusive table lock and if using, use it in the same sequence and use Commit
frequently to release locks.

Q.Where the Pre_defined_exceptions are stored ?


In the standard package.
Procedures, Functions & Packages ;

Q. Below is the table


city gender name
delhi male a
delhi female b
mumbai male c
mumbai female d
delhi male e
I want the o/p as follows:
male female
delhi 2 1
mumbai 1 1
Please help me in writing the query that can yield the o/p mentioned above?
select city, sum(decode(gender,'male',1,0)) Male_cnt, sum(gender,'female',1,0)
female_cnt
from table_name
group by city
select a.city,a.male,b.female from
(select city,count(gender) male from city where gender='m'group by city,gender)a
join
(select city,count(gender) female from city where gender='f' group by city,gender)b
on a.city=b.city

Q.What is Sequences?
Sequences are used for generating sequence numbers without any overhead of locking.
Drawback is that after generating a sequence number if the transaction is rolled back,
then that sequence number is lost

Q.What are % TYPE and % ROWTYPE ? What are the advantages of using these
over datatypes?
% TYPE provides the data type of a variable or a database column to that variable.
% ROWTYPE provides the record type that represents a entire row of a table or view or
columns selected in the cursor.
The advantages are : I. Need not know about variable's data type
ii. If the database definition of a column in a table changes, the data type of a variable
changes accordingly.

Q.What is Mutating SQL Table?


Mutating Table is a table that is currently being modified by an Insert, Update or Delete
statement. Constraining Table is a table that a triggering statement might need to read
either directly for a SQL statement or indirectly for a declarative Referential Integrity
constraints. Pseudo Columns behaves like a column in a table but are not actually stored
in the table. E.g. Currval, Nextval, Rowid, Rownum, Level etc.

Q.What is PL/SQL table ?


Objects of type TABLE are called "PL/SQL tables", which are modeled as (but not the
same as) database tables, PL/SQL tables use a primary PL/SQL tables can have one
column and a primary key.
Cursors
PL/SQL tables are PL/SQL?s way of providing arrays. Arrays are like tem-porary
tables in memory and thus are processed very quickly. It is impor-tant
for you to realize that they are not database tables, and DML
statements cannot be issued against them. This type of table is indexed
by a binary integer counter (it cannot be indexed by another type of
number) whose value can be referenced using the number of the index.
Remember that PL/SQL tables exist in memory only, and therefore don't
exist in any persistent way, disappearing after the session ends.
A PL/SQL TABLE DECLARATION
There are two steps in the declaration of a PL/SQL table. First, you must define the table
structure using the TYPE statement. Second, once a table type is created, you then
declare the actual table.
FOR EXAMPLE
DECLARE
-- Table structure definition
TYPE NameType IS TABLE OF
Customer.name_name%TYPE
INDEX BY BINARY_INTEGER;
-- Create the actual table
CnameTab NameType;
KnameTab NameType;
BEGIN
NULL; -- ...
END;

Q.In a Distributed Database System Can we execute two queries


simultaneously? Justify?
Yes, Distributed database system based on 2 phase commit,one query is independent of
2 nd query so of course we can run.

Q.What are the modes of parameters that can be passed to a procedure ?


IN parameter is the default mode which acts as a constant inside calling
environment.value passed in this parameter can not be changed.OUT parameter mode is
used to pass value from calling environment into main block,here we can change the
value.It acts as a variable inside calling environment.
INOUT parameter mode which pass value into calling environment and will get the value
back in main block.
IN parameter mode uses call by reference method to pass value from formal parameter
to actual parameter.
OUT & INOUT parameter mode uses call by value method to pass values.
IN,OUT,IN-OUT parameters.

Q.Name the tables where characteristics of Package, procedure and functions


are stored?
User_objects, User_Source and User_error.

Q.How many types of database triggers can be specified on a table? What are
they?
Insert Update Delete
Before Row o.k. o.k. o.k.
After Row o.k. o.k. o.k.
Before Statement o.k. o.k. o.k.
After Statement o.k. o.k. o.k.
If FOR EACH ROW clause is specified, then the trigger for each Row affected by the
statement.
If WHEN clause is specified, the trigger fires according to the returned Boolean value.

Q.How can a function retun more than one value in oracle with proper example?
Basically as per property of function it has to return one value. So the other values can
be returned from the out parameter of the function.
But its advised if you want more that one return value go for procedure however function
will also yield the same result.

Q.Explain If the entire disk is corrupted how will you and what are the steps to
recover the database?
if the entire disk is corrupted and no backup is there don nothing sit and relax their is no
possibility of recovery ...a backup is required for restoration and for recovery redo log
and archive logs.
Once if you have theses than think of recovering ..a dba should always plan for the
recovery scenario depending upon the criticality of the database.oracle provides 0% data
loss facilty through data guard and online backup .its dba who has to decide.
Q.What is Rollback?
Rollback causes work in the current transaction to be undone.

Q.What is a cursor for loop ?


Cursor for loop implicitly declares %ROWTYPE as loop index,opens a cursor, fetches rows
of values from active set into fields in the record and closes when all the records have
been processed.
eg. FOR emp_rec IN C1 LOOP
salary_total := salary_total +emp_rec sal;
END LOOP;

Q.How to sort the rows in SQL?


Sort the Rows:
SELECT column1, column2, ... FROM table_name ORDER BY columnX, columnY, ..
SELECT column1, column2, ... FROM table_name ORDER BY columnX DESC
SELECT column1, column2, ... FROM table_name ORDER BY columnX DESC, columnY
ASC1.
select column1,column2,column3 from table1
where
column1>10
order by 1,3,2;
Inthis case it sorts based on the columns' position in the select query i.e. in the above
query it will sort first based on column1 then on column3 and then by column2. By
default the sort is in ascending order, if you want it to be in descending order, you need
to specify the key word DESC in ORDER BY clause.
2.select * from emp order by eno desc;
You can sort your results based on any column in the tables because you are select all
the columns.
3.select eno,ename from emp order by deptno;
This is wrong because the column deptno is not present in the select clause.

Q.What is Pragma EXECPTION_INIT? Explain the usage?


The PRAGMA EXECPTION_INIT tells the complier to associate an exception with an oracle
error. To get an error message of a specific oracle error.
e.g. PRAGMA EXCEPTION_INIT (exception name, oracle error number

Q.What's the use of dyanamic sql in oracle?


Dynamic SQL enables you to write programs that reference SQL statements whose full
text is not known until runtime.

Q.How we can create a table in PL/SQL block. insert records into it? is it
possible by some procedure or function? please give example?
CREATE OR REPLACE PROCEDURE ddl_create_proc (p_table_name IN VARCHAR2)
AS
l_stmt VARCHAR2(200);
BEGIN
DBMS_OUTPUT.put_line('STARTING ');
l_stmt := 'create table '|| p_table_name || ' as (select * from emp )';
execute IMMEDIATE l_stmt;
DBMS_OUTPUT.put_line('end ');
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.put_line('exception '||SQLERRM || 'message'||sqlcode);
END;

Q.What is a JOIN?
JOIN is the form of SELECT command that combines info from two or more tables.
Types of Joins are Simple (Equijoin & Non-Equijoin), Outer & Self join.
Equijoin returns rows from two or more tables joined together based upon a equality
condition in the WHERE clause.
Non-Equijoin returns rows from two or more tables based upon a relationship other than
the equality condition in the WHERE clause.
Outer Join combines two or more tables returning those rows from one table that have no
direct match in the other table.
Self Join joins a table to itself as though it were two separate tables.

Q.what is the starting oracle error number?


what is meant by forward declaration in functions?
One must declare an identifier before referencing it. Once it is declared it can be referred
even before defining it in the PL/SQL. This rule applies to function and procedures also.

Q.Can we declare a column having number data type and its scale is larger than
pricesion
ex: column_name NUMBER(10,100),
column_name NUMBAER(10,-84)
No, you cant. May be your table might be created successfully but if you try to insert
values it will shows you an error.
Numeric or Value Error
NUMBER (p,s)
p- precision, which is the total size of digits
s- scale , which represents the total number of digits that are present to the right side of
the decimal.
s should be strictly less than p. If I am missing somthing. Please fill me in.
Yes,we can declare a column with above condition.table created successfully.
yes, 100 is the total size and 10 is included in 100

Q.Is it possible to use Transaction control Statements such a ROLLBACK or


COMMIT in Database Trigger? Why?
It is not possible. As triggers are defined for each table, if you use COMMIT of ROLLBACK
in a trigger, it affects logical transaction processing.
yes WE can use COMMIT and ROLLBACK triggers, but by using PRAGAMA
AUTONAMOUS_TRANSATIONS. Now the transation treated as a autonomous tansation.
Q.What is COLUMN?
COLUMN command define column headings & format data values.

Q.SELECT statements in SQL?


SELECT column_name(s) FROM table_name
SELECT DISTINCT column_name(s) FROM table_name
SELECT column FROM table WHERE column operator value
SELECT column FROM table WHERE column LIKE pattern
SELECT column,SUM(column) FROM table GROUP BY column
SELECT column,SUM(column) FROM table GROUP BY column HAVING SUM(column)
condition value
Note that single quotes around text values and numeric values should not be enclosed in
quotes. Double quotes may be acceptable in some databases.

Q.What is the Delete Statements in SQL?


Delete statement in SQL is used to delete partial/all data.
Especially delete statement is useful in case of partial delete depending upon our criterias
otherwise use TRUNCATE to delete whole data from table.
When delete command fires then:
1) Triggers will fire (If created on that table)
2) This will not auto commit changes made So there is one chance to rollback.
3) If u delete whole data then HWM (Highest Water Mark) will not change which gets
changed in case of Truncate.

Q.What is Posting?
Posting is an event that writes Inserts, Updates & Deletes in the forms to the database
but not committing these transactions to the database.

Q.Where the Pre_defined_exceptions are stored?


In the standard package.
Procedures, Functions & Packages ;

Q.What are two parts of package?


The two parts of package are PACKAGE SPECIFICATION & PACKAGE BODY. Package
Specification contains declarations that are global to the packages and local to the
schema.
Package Body contains actual procedures and local declaration of the procedures and
cursor declarations.

Q.What are the datatypes a available in PL/SQL?


Some scalar data types such as
NUMBER,
VARCHAR2,
DATE,
CHAR,
LONG,
BOOLEAN.
Some composite data types such as RECORD & TABLE.

Q.What is an Exception? What are types of Exception?


Exception is the error handling part of PL/SQL block. The types are Predefined and user
defined. Some of Predefined exceptions are.
CURSOR_ALREADY_OPEN
DUP_VAL_ON_INDEX
NO_DATA_FOUND
TOO_MANY_ROWS
INVALID_CURSOR
INVALID_NUMBER
LOGON_DENIED
NOT_LOGGED_ON
PROGRAM-ERROR
STORAGE_ERROR
TIMEOUT_ON_RESOURCE
VALUE_ERROR
ZERO_DIVIDE
OTHERS.
exception is an identifier and error handling part of pl/sql types := 1)predifined 2) user
defined.

Q.Explian rowid, rownum?what are the psoducolumns we have?


ROWID - Hexa decimal number each and every row having unique.Used in searching.
ROWNUM - It is a integer number also unique for sorting Normally TOP N Analysys.
Other Psudo Column are
NEXTVAL,CURRVAL Of sequence are some exampls
psudo columns are default columns provided by oracle

Q.How to avoid using cursors? What to use instead of cursor and in what cases
to do so?
Just use subquery in for clause
ex:For emprec in (select * from emp)
loop
dbms_output.put_line(emprec.empno);
end loop;
no exit statement needed
implicit open,fetch,close occurs

Q.what is the starting oracle error number?


what is meant by forward declaration in functions?
One must declare an identifier before referencing it. Once it is declared it can be referred
even before defining it in the PL/SQL. This rule applies to function and procedures also
ORA-20000
Q.What are the components of a PL/SQL block?
A set of related declarations and procedural statements is called block.
DECLARE -- declaration section BEGIN -- executable statements -- main section
EXCEPTION -- handling possible exceptions -- occuring in the main section END;

Q.What is difference between stored procedures and application


procedures,stored function and application function?
Stored procedures are sub programs stored in the database and can be called & execute
multiple times where in an application procedure is the one being used for a particular
application same is the way for function
Procedure:-
Execute as a PL/SQL
statement,No RETURN clause in
the header,Can return none, one,
or many values,Can contain a RETURN
statement
Function:-Invoke as part of an
expression,Must contain a RETURN
clause in the header,Must return a single value,Must contain at least one RETURN
statement

Q.What is Raise_application_error ?
Raise_application_error is a procedure of package DBMS_STANDARD which allows to
issue an user_defined error messages from stored sub-program or database
trigger.

Q.What is trigger,cursor,functions in pl-sql and we need sample programs about


it?
Trigger is an event driven PL/SQL block. Event may be any DML transaction.
Cursor is a stored select statement for that current session. It will not be stored in the
database, it is a logical component.
Function is a set of PL/SQL statements or a PL/SQL block, which performs an operation
and must return a value.

Q.How we can create a table in PL/SQL block. insert records into it??? is it
possible by some procedure or function?? please give example...
CREATE OR REPLACE PROCEDURE ddl_create_proc (p_table_name IN VARCHAR2)
AS
l_stmt VARCHAR2(200);
BEGIN
DBMS_OUTPUT.put_line('STARTING ');
l_stmt := 'create table '|| p_table_name || ' as (select * from emp )';
execute IMMEDIATE l_stmt;
DBMS_OUTPUT.put_line('end ');
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.put_line('exception '||SQLERRM || 'message'||sqlcode);
END;

Q.In pl/sql functions what is use of out parameter even though we have return
statement.
With out parameters you can get the more than one out values in the calling program. It
is recommended not to use out parameters in functions. If you need more than one out
values then use procedures instead of functions.

Q.How to debug the procedure ?


You can use DBMS_OUTPUT oracle supplied package or DBMS_DEBUG pasckage.

Q.What is ref cursor?


In PL/SQL ,pointer has a datatype REF X where
REF-Reference
X-class of objects
Cursor Variables has a datatype REF-CURSOR
where Cursor Varibales are like pointers which hold the memory location of some item
instead of the item itself.

Q.State the advantage and disadvantage of Cursor?


Advantage :
In pl/sql if you want perform some actions more than one records you should user these
cursors only. bye using these cursors you process the query records. you can easily move
the records and you can exit from procedure when you required by using cursor
attributes.
disadvantage:
using implicit/explicit cursors are depended by sutiation. if the result set is les than 50 or
100 records it is better to go for implicit cursors. if the result set is large then you should
use exlicit cursors. other wise it will put burdon on cpu.

Q.What is a database trigger ? Name some usages of database trigger ?


A database triggers is stored PL/SQL program unit associated with a specific database
table or view. The code in the trigger defines the action the database needs to perform
whenever some database manipulation (INSERT, UPDATE, DELETE) takes place.
Unlike the stored procedure and functions, which have to be called explicitly, the
database triggers are fires (executed) or called implicitly whenever the table is affected
by any of the above said DML operations.
Till oracle 7.0 only 12 triggers could be associated with a given table, but in higher
versions of Oracle there is no such limitation. A database trigger fires with the privileges
of owner not that of user
A database trigger has three parts
1. A triggering event
2. A trigger constraint (Optional)
3. Trigger action
A triggering event can be an insert, update, or delete statement or a instance shutdown
or startup etc. The trigger fires automatically when any of these events occur A trigger
constraint specifies a Boolean expression that must be true for the trigger to fire. This
condition is specified using the WHEN clause. The trigger action is a procedure that
contains the code to be executed when the trigger fires.
Database trigger is stored PL/SQL program unit associated with a specific database table.
Usages are Audit data modifications, Log events transparently, Enforce complex business
rules Derive column values automatically, Implement complex security authorizations.
Maintain replicate tables.

Q.What are the return values of functions SQLCODE and SQLERRM ?


SQLCODE returns the latest code of the error that has occurred.
SQLERRM returns the relevant error message of the SQLCODE.

Q.How packaged procedures and functions are called from the following?
a. Stored procedure or anonymous block
b. an application program such a PRC *C, PRO* COBOL
c. SQL *PLUS
a.PACKAGE NAME.PROCEDURE NAME (parameters);
variable := PACKAGE NAME.FUNCTION NAME (arguments);
EXEC SQL EXECUTE
b.
BEGIN
PACKAGE NAME.PROCEDURE NAME (parameters)
variable := PACKAGE NAME.FUNCTION NAME (arguments);
END;
END EXEC;
c. EXECUTE PACKAGE NAME.PROCEDURE if the procedures does not have any out/in-out
parameters. A function can not be called.

Q.Operators used in SELECT statements are?


= Equal
<> or != Not equal
> Greater than
< Less than
>= Greater than or equal
<= Less than or equal
BETWEEN Between an inclusive range
LIKE Search for a pattern

Q.Give the structure of the procedure ?


basically procedure has three
parts
1.variable declaretion(optional)
2.body(mandetory)
3.Exception(optional)
suppose ex
CREATE OR REPLACEPROCEDURE emp_pro( p_id IN employees.employee_id%TYPE)
IS
v_name employees.last_name%TYPE;
v_mail employees.email%TYPE;
BEGIN
SELECT last_name,email INTO v_name,v_mail FROM employees
WHERE employee_id:=p_id;
DBMS_OUTPUT.PUT_LINE('NAME:'||v_name ||'MAILID:'||v_mail);
END;
/
PROCEDURE name (parameter list.....)
is
local variable declarations
BEGIN
Executable statements.
Exception.
exception handlers
end;

Q.What is SPOOL?
spool command used for printing the out put of the sql statments in a file. Eg.
spool /tmp/sql_out.txt
select emp_name, emp_id from emp where dept='sales';
spool off;
we can see the out on /tmp/sql_out.txt file.
SPOOL command creates a print file of the report.

Q.What are advantages fo Stored Procedures


Extensibility,Modularity, Reusability, Maintainability and one time compilation.

Q.IS Stored Function Is Pre-Compiled as Stored Procedure ? If No Why


stored procedure means the pre-compiled precedure ,which is used for a specific action to
be executed more than one times whenever you called from coding in the programe.
stored procedure is an important concept in the application developement in oracle.

Q.Explain the two type of Cursors ?


There are two types of cursors, Implicit Cursor and Explicit Cursor.
PL/SQL uses Implicit Cursors for queries. User defined cursors are called Explicit Cursors.
They can be declared and used.

Q.What is Overloading of procedures ?


Overloading of procedure
name of the procedure is
same but the number of parameters should be different.In that case,procedure will be
overloaded.
2. if the number of parameters are same in that case,data type should be different.
if the two rules are satisfied in that case procedure will be overloaded.

Q.What is PL/SQL ?
PL/SQL is a procedural language that has both interactive SQL and procedural
programming language constructs such as iteration, conditional branching.

Q.What are the PL/SQL Statements used in cursor processing ?


DECLARE CURSOR cursor name, OPEN cursor name, FETCH cursor name INTO or Record
types, CLOSE cursor name.

Q.What is Set Transaction?


Set Transaction is to establish properties for the current transaction.

Q.What is Character Functions?


Character Functions are INITCAP, UPPER, LOWER, SUBSTR & LENGTH. Additional
functions are GREATEST & LEAST. Group Functions returns results based upon groups of
rows rather than one result per row, use group functions. They are AVG, COUNT, MAX,
MIN & SUM.

Q.What is an Exception ? What are types of Exception?


Exception is the error handling part of PL/SQL block. The types are Predefined and user
defined. Some of Predefined exceptions are.
CURSOR_ALREADY_OPEN
DUP_VAL_ON_INDEX
NO_DATA_FOUND
TOO_MANY_ROWS
INVALID_CURSOR
INVALID_NUMBER
LOGON_DENIED
NOT_LOGGED_ON
PROGRAM-ERROR
STORAGE_ERROR
TIMEOUT_ON_RESOURCE
VALUE_ERROR
ZERO_DIVIDE
OTHERS.

Q.Is it possible to use Transaction control Statements such a ROLLBACK or


COMMIT in Database Trigger? Why?

It is not possible. As triggers are defined for each table, if you use COMMIT of ROLLBACK
in a trigger, it affects logical transaction processing.
yes WE can use COMMIT and ROLLBACK triggers, but by using PRAGAMA
AUTONAMOUS_TRANSATIONS. Now the transation treated as a autonomous tansation.
Q.What is Multiple columns?
Multiple columns can be returned from a Nested Subquery.

Q.What is Savepoint?
Savepoint is a point within a particular transaction to which you may rollback without
rolling back the entire transaction.
-----------------------------------------------------
Also Read:

SQL and PL / SQL Interview


Questions -2
Posted in: pl/sql,SQL,SQL Basics,sql guide,SQL Interview Questions,SQL Interview Questions and Answers

Email ThisBlogThis!Share to TwitterShare to Facebook

You might also like