Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Data dictionary in Oracle contains information about all database objects such as
tables, triggers, stored procedures, functions, indexes, constraints, views, users,
roles, monitoring information, etc.
Q. Which data dictionary objects are used to retrieve the information about the
following objects from a given schema?
1) tables
2) views
3) triggers
4) procedures
5) constraints
6) all of the above mentioned objects
fferent SQL queries in the same PL/SQL program vs. design time declared explicit
cursors with an association to only one query.
Q. You want to view top 50 rows from Oracle table. How do I this?
After complete execution of query and before displaying output of SQL query to
the user oracle internally assigns sequential numbers to each row in the output.
These numbers are held in the hidden column or pseudo column that is a
ROWNUM column. Now it is so simple to apply the above logical condition, as you
would have done to any other column of the table.
Q. How do you reference column values in BEFORE and AFTER insert and delete
triggers?
The BEFORE and AFTER insert triggers can reference column values by new
collection using keyword “:new.column name”. The before and after delete
triggers can reference column values by old collection using keyword “:old.
column name”.
Q. Can you change the inserted value in one of the columns in AFTER insert
trigger code?
This is not possible as the column values supplied by the insert SQL query are
already inserted into the table. If you try to assign new value to the column in
AFTER insert trigger code then oracle error would be raised. To alter any values
supplied by insert SQL query create BEFORE insert trigger.
SYSDATE is a pseudo column and refers to the current server system date. USER
is a pseudo column and refers to the current user logged onto the oracle session.
These values come handy when you want to monitor changes happening to the
table.
Explicit cursors are created programmatically. The cursor type variable is declared
and associated with SQL query. The program then opens a cursor, fetches column
information into variables or record type variable, and closes cursor after all
records are fetched. To check whether cursor is open or not use function
SQL%ISOPEN and to check whether there are any records to be fetched from the
cursor use function SQL%FOUND.
Q. Why does a query in Oracle run faster when ROWID is used as a part of the
where clause?
b> NO_DATA_FOUND
c> DUP_VAL_ON_INDEX
PL-SQL Interview Questions with Answers
2. What is a mutating table error and how can you get around it?
Level: Intermediate
Expected answer: This happens with triggers. It occurs because the trigger is
trying to update a row it is currently using. The usual fix involves either use of
views or temporary tables so the database is selecting from one while updating
the other.
4. What packages (if any) has Oracle provided for use by developers?
Expected answer: Oracle provides the DBMS_ series of packages. There are many
which developers should be aware of such as DBMS_SQL, DBMS_PIPE,
DBMS_TRANSACTION,
DBMS_LOCK, DBMS_ALERT, DBMS_OUTPUT, DBMS_JOB, DBMS_UTILITY,
DBMS_DDL, UTL_FILE. If they can mention a few of these and describe how they
used them, even better. If they include the SQL routines provided by Oracle,
great, but not really what was asked.
8. What are SQLCODE and SQLERRM and why are they important for PL/SQL
developers?
Expected answer: SQLCODE returns the value of the error number for the last
error encountered. The SQLERRM returns the actual error message for the last
error encountered. They can be used in exception handling to report, or, store in
an error log table, the error that occurred in the code. These are especially useful
for the WHEN OTHERS exception.