pl sql interview questions
pl sql interview questions
True or False ?
Routines written in PL/SQL can be called in Oracle call interface, Java, Pro*C/C++, COBOL
etc.
True.
True or False ?
PL/SQL does not have data types or variables.
False. PL/SQL has all features of a structured programming language including data types,
variables, subroutines, modules and procedural constructs.
Declaration section
Execution section
Exception section
What is wrong in the following assignment statement?
balance = balance + 2000;
Use of wrong assignment operator. The correct syntax is: balance := balance + 2000;
Write a single statement that concatenates the words ‘Hello’ and ‘World’ and assign it in a
variable named greeting.
greeting := ‘Hello’ || ‘World’;
NOT
Which of the following operator has the lowest precedence among the following −
**, OR, NULL ?
OR
The colon (: )sign implies that the variable :deficit is an external variable.
dcode := dept.detpno%type;
The variable dcode is created with the same data type as that of the deptno column of the dept
table.
For example
emptype := emp%rowtype;
name := emptype.empname;
What is a trigger?
A trigger is a PL/SQL program that is stored in the database and executed immediately before
or after the INSERT, UPDATE, and DELETE commands.
True or False ?
PL/SQL engine is part of Oracle Server.
True.
True or False ?
The BEGIN declaration starts the variable declaration sections of a PL/SQL block.
True or False ?
The PL/SQL engine executes the procedural commands and passes the SQL commands for the
Oracle server to process.
True.
True or False ?
PL/SQL supports the CREATE command.
False. PL/SQL doesn’t support the data definition commands like CREATE.
True or False ?
Triggers can be associated to a view.
True.
True or False ?
When a trigger is associated to a view, the base table triggers are normally disabled.
False. When a trigger is associated to a view, the base table triggers are normally enabled.
True or False ?
A trigger can perform the role of a constraint, forcing an integrity rule.
True.
True or False ?
A trigger can execute the COMMIT, ROLLBACK, or SAVEPOINT commands.
True or False ?
Statement level triggers are triggered only once.
True.
What is the purpose of the optional argument [OR REPLACE] in a CREATE TRIGGER
command?
The optional argument [OR REPLACE] in a CREATE TRIGGER command re-creates an
existing trigger. Using this option allows changing the definition of an existing trigger without
having to delete it first.
True or False ?
INSTEAD OF is a valid option only for triggers in a table.
False. INSTEAD OF is a valid option only for views. INSTEAD OF trigger cannot be specified
in a table.
<exception_name> EXCEPTION;
What are the steps that need to be performed to use an explicit cursor? Discuss briefly.
The steps that need to be performed on explicit cursor are −
DECLARE − assigns a name to the cursor and defines the structure of query within it.
OPEN − executes the query, whereby the rows returned by the query are available for
fetching.
FETCH − assigns values from the current row (cursor position) into specified variables.
PL/SQL packages usually have two parts. What are these two parts?
PL/SQL packages have two parts −
How do you refer to the types, objects and subprograms declared within a package?
The types, objects, and subprograms declared within a package are referred to using the dot
notation as −
package_name.type_name
package_name.object_name
package_name.subprogram_name
True or False ?
PL/SQL allows subprogram overloading feature within a package.
True.
True or False ?
The %NOTFOUND attribute returns true when the cursor is not created explicitly.
False. The %NOTFOUND attribute returns true when the last row of the cursor is processed
and no other row is available.
True or False ?
The %ROWCOUNT attribute returns the total number of rows returned by the FETCH
command.
True.