Vous êtes sur la page 1sur 4

PL-SQL Interview Questions with Answers

1. Describe the difference between a procedure, function and anonymous pl/sql block.
Level: Low
Expected answer : Candidate should mention use of DECLARE statement, a function must return a value while a
procedure doesn't have to.

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.

3. Describe the use of %ROWTYPE and %TYPE in PL/SQL


Level: Low
Expected answer: %ROWTYPE allows you to associate a variable with an entire table row.
The %TYPE associates a variable with a single column type.

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.

5. Describe the use of PL/SQL tables


Expected answer: PL/SQL tables are scalar arrays that can be referenced by a
binary integer. They can be used to hold values for use in later queries
or calculations. In Oracle 8 they will be able to be of the %ROWTYPE designation, or RECORD.

6. When is a declare statement needed ?


The DECLARE statement is used in PL/SQL anonymous blocks such as with stand alone, non-stored PL/SQL
procedures. It must come first in a PL/SQL stand alone file if it is used.

7. In what order should a open/fetch/loop set of commands in a PL/SQL block be implemented if you use the
NOTFOUND cursor variable in the exit when statement? Why?
Expected answer: OPEN then FETCH then LOOP followed by the exit when. If not specified in this order will
result in the final return being done twice because of the way the %NOTFOUND is handled by PL/SQL.

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.

9. How can you find within a PL/SQL block, if a cursor is open?


Expected answer: Use the %ISOPEN cursor status variable.

10. How can you generate debugging output from PL/SQL?


Expected answer: Use the DBMS_OUTPUT package. Another possible method is to just use the SHOW ERROR
command, but this only shows errors. The DBMS_OUTPUT package can be used to show intermediate results from
loops and the status of variables as the procedure is executed. The new package UTL_FILE can
also be used.
11. What are the types of triggers?
Expected Answer: There are 12 types of triggers in PL/SQL that consist of
combinations of the BEFORE, AFTER, ROW, TABLE, INSERT, UPDATE, DELETE and
ALL key words:
BEFORE ALL ROW INSERT
AFTER ALL ROW INSERT
BEFORE INSERT
AFTER INSERT etc.
 What is the starting "oracle error number"? 2)What is meant by forward declaration in functions?
 Can Commit,Rollback ,Savepoint be used in Database Triggers?If yes than HOW? If no Why?With Reasons
 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)
 Explain how procedures and functions are called in a PL/SQL block ?
 Explain the two type of Cursors ?

-- Sponsored Links --
Embedded Course with Job
Trained 1500 Embedded Professionals since 2004. Join Oasis Tech Pune.

Your Ad Here

 Explain the usage of WHERE CURRENT OF clause in cursors ?


 Explian rowid,rownum?What are the pseduocolumns we have?
 Give the structure of the function ?
 Give the structure of the procedure ?
 How many types of database triggers can be specified on a table ? What are they ?
 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
 How to avoid using cursors? What to use instead of cursor and in what cases to do so?
 How to debug the procedure ?
 How to disable multiple triggers of a table at at a time?
 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...
 How we can create a table through procedure ?

-- Sponsored Links --
Herbal Ephedra Diet Pills
Buy Metabadrene 356, Hydroxyslim, Herbalean, Curvelle, Zenalean RFA1

Your Ad Here

 In a Distributed Database System Can we execute two queries simultaneously ? Justify ?


 In pl/sql functions what is use of out parameter even though we have return statement.
 Whar are Integarity Constraints?
 Is it possible to use Transaction control Statements such a ROLLBACK or COMMIT in Database Trigger ?
Why ?
 Name the tables where characteristics of Package, procedure and functions are stored ?
 Open C1; Fetch c1 into Z; Commit; Fetch c1 in to Z; end;
 State the advantage and disadvantage of Cursor?
 State the difference between implicit and explicit cursor's.
 What are % TYPE and % ROWTYPE ? What are the advantages of using these over datatypes?
 What are advantages fo Stored Procedures
 What are the PL/SQL Statements used in cursor processing ?
 What are the Restrictions on Cursor Variables?
 What are the components of a PL/SQL Block ?
 What are the cursor attributes used in PL/SQL ?
 What are the datatypes a available in PL/SQL ?
 What are the modes of parameters that can be passed to a procedure ?
 What are the return values of functions SQLCODE and SQLERRM ?
 What are the two parts of a procedure ?
 What are two parts of package ?
 What are two virtual tables available during database trigger execution ?
 What happens if a procedure that updates a column of table X is called in a database trigger of the same table ?
 What is Overloading of procedures ?
 What is PL/SQL ?
 What is PL/SQL table ?
 What is Pragma EXECPTION_INIT ? Explain the usage ?
 What is Raise_application_error ?
 What is a cursor ? Why Cursor is required ?
 What is a cursor for loop ?
 What is a database trigger ? Name some usages of database trigger ?
 What is a stored procedure ?
 What is an Exception ? What are types of Exception ?
 What is difference between % ROWTYPE and TYPE RECORD ?
 What is difference between a Cursor declared in a procedure and Cursor declared in a package specification ?
 What is difference between a PROCEDURE & FUNCTION ?
 What is difference between stored procedures and application procedures,stored function and application
function?
 What is pl/sql?what are the advantages of pl/sql?
 What is ref cursor.
 What is the basic structure of PL/SQL ?
 What is trigger,cursor,functions in pl-sql and we need sample programs about it?
 What will happen after commit statement ?
 What will the Output for this Coding> Declare Cursor c1 is select * from emp FORUPDATE; Z c1%rowtype;
Begin
 Where the Pre_defined_exceptions are stored ?
 Write the order of precedence for validation of a column in a table ? I. done using Database triggers. ii. done
using

Vous aimerez peut-être aussi