You are on page 1of 8

Share Report Abuse Next Blog Create Blog Sign In RSS Feed SQL PL/SQL Interview Questions These

questions will be updated and new questions will be added on regular basis , so stay tuned and subscribe to RSS Feed. What special operators does Oracle provide for dealing with NULLs? NVL - Converts a NULL to another specified value, as in: my_var := NVL (your_var, 'Hello'); IS NULL and IS NOT NULL You can use this syntax to check specificaly to see if a variable's value is NUL L or NOT NULL. Explain three different rules that apply to NULLs when doing comparisons? 1. For all operators except for concatenation (||), if a value in an expression is a NULL, that expression evaluates to NULL 2. NULL is never equal or not equal to another value 3. NULL is never TRUE or FALSE What command would you use to encrypt a PL/SQL application? WRAP Explain the difference between a FUNCTION, PROCEDURE and PACKAGE. A function has a return type in its specification and must return a value specif ied in that type. A procedure does not have a return type in its specification and should no t return Oracle SQL & PL/SQL Oracle SQL SQL Introduction SQL Syntax SQL Select SQL Insert SQL Update SQL Delete SQL Joins SQL Examples of Joins SQL Explicit vs. Implicit Joins SQL Group By SQL Group By Examples SQL Having SQL - IN SQL - NULLs Functional Dependencies Normalization ACID Properties SQL SubQueries SQL - Queries With Examples SQL Views Insert, Update, Delete Views SQL Join Views SQL Inline Views SQL - Nth Highest Salary SQL Second Highest Salary SQL - Difference Truncate / Delete SQL - Difference Truncate / Drop SQL - Difference HAVING / WHERE SQL - Difference CAST / CONVERT SQL - Difference NOT IN / NOT EXIST SQL - Difference IN / EXISTS SQL - Difference UNION / UNION ALL

SQL - Difference Nested / Correlated Subquery SQL - REPLACE SQL - TOP SQL - LIKE SQL - SELECT INTO SQL - CREATE TABLE SQL - CREATE TABLE (More Examples) SQL - ALTER TABLE SQL - Difference views / Materialized views SQL Count SQL Update SQL Clustered / Non-Clustered Indexes SQL - Delete Duplicate Records SQL - Difference Unique/Primary Key SQL - GETDATE() SQL - DATEDIFF() SQL - DATEADD() SQL - DATEPART() SQL - Convert() SQL - SUM() SQL - AVG() Ads by Google SQL Query Interview Questions SQL Server Tutorial Function PL SQL Oracle SQL & PL/SQL: SQL PL/SQL Interview Questions http://sql-plsql.blogspot.co m/2007/04/sql-plsql-interview-questions.html 1 of 5 10-10-11 6:42 AM SQL PL/SQL Interview Questions SQL PL/SQL Interview Questions SQL any value, but it can have a return statement that simply stops its execution an d returns to the caller. What steps are included in the compilation process of a PL/SQL block? The compilation process includes syntax checking, binding, and p-code generation . Syntax checking involves checking PL/SQL code for compilation errors. After synt ax errors have been corrected, a storage address is assigned to the variables that are used to hold data for Oracle. This process is called binding. Next, p-code is ge nerated for the PL/SQL block. P-code is a list of instructions to the PL/SQL engine. For named blocks, p-code is stored in the database, and it is used the next time the progr am is executed. How does a syntax error differ from a runtime error? A syntax error can be detected by the PL/SQL compiler. A runtime error occurs wh ile the program is running and cannot be detected by the PL/SQL compiler.

A misspelled keyword is an example of a syntax error. For example, this script: BEIN DBMS_OUTPUT.PUT_LINE ('This is a test'); END; contains a syntax error. Try to find it. A SELECT INTO statement returning no rows is an example of a runtime error. This error can be handled with the help of the exception-handling section of the PL/S QL block. Define Commit, Rollback and Savepoint. When a COMMIT statement is issued to the database, the transaction has ended, an d the following results are true: . All work done by the transaction becomes permanent. . Other users can see changes in data made by the transaction. . Any locks acquired by the transaction are released. When a ROLLBACK statement is issued to the database, the transaction has ended, and the following results are true: . All work done by the transaction is undone, as if it hadn t been issued. . Any locks acquired by the transaction are released. The ROLLBACK statement undoes all the work done by the user in a specific transaction. With the SAVEPOINT command, however, only part of the transaction c an be undone. Explain Implicit and Explicit cursors Oracle automatically declares an implicit cursor every time a SQL statement is executed. The user is unaware of this and cannot control or process the informat ion in an implicit cursor. The program defines an explicit cursor for any query that returns more than one row of data. This means that the programmer has declared the cursor within the PL/SQ L code block. This declaration allows the application to sequentially process each row of data as the cursor returns it. How an Implicit cursor works? SQL - MIN() SQL - MAX() SQL - Insert Into Select SQL - Insert Multiple Values In Table SQL - Referential Integrity SQL - Not Null Constraint SQL - Unique Constraint SQL - Primary Key Constraint SQL - Foreign Key Constraint SQL - Default Constraint SQL - Check Constraint SQL - ROLLUP SQL - CUBE SQL - STUFF() SQL - Count_Big SQL - Binary_Checksum SQL - Checksum_AGG SQL - Index Include SQL - Covered Query SQL - Identity SQL - sp_columns SQL - Diff Local/Global Temporary Tables SQL - Stored Procedure

SQL - sp_who SQL - Session SQL - Dynamic SQL SQL - SQL Server Execution Plan SQL Interview Questions Oracle PL/SQL PL/SQL Introduction PL/SQL Procedures PL/SQL Functions PL/SQL Collections PL/SQL Records PL/SQL Table Based Records PL/SQL Programmer Defined Records PL/SQL Cursor Based Records PL/SQL Tables PL/SQL Varrays PL/SQL Nested Tables PL/SQL Loops PL/SQL Triggers PL/SQL Cursors PL/SQL Implicit Cursors PL/SQL Explicit Cursors PL/SQL REF Cursors PL/SQL Cursor For Loop PL/SQL Cursors with Parameters PL/SQL Where Current Of and For Update Examples of PL/SQL Cursors PL/SQL Exceptions PL/SQL Interview Questions SQL PL/SQL Sitemap Oracle SQL & PL/SQL: SQL PL/SQL Interview Questions http://sql-plsql.blogspot.co m/2007/04/sql-plsql-interview-questions.html 2 of 5 10-10-11 6:42 AM PL/SQL Interview Questions SQL PL/SQL Interview Questions SQL PL/SQL Interview Questions SQL PL/SQL Interview Questions SQL PL/SQL Interview Questions SQL PL/SQL Interview Questions SQL PL/SQL Any given PL/SQL block issues an implicit cursor whenever a SQL statement is executed, as long as an explicit cursor does not exist for that

SQL statement. 1. A cursor is automatically associated with every DML (data manipulation) statement (UPDATE, DELETE, INSERT). 2. All UPDATE and DELETE statements have cursors that identify the set of rows that will be affected by the operation. 3. An INSERT statement needs a place to receive the data that is to be inserted into the database; the implicit cursor fulfills this need. 4. The most recently opened cursor 5. is called the SQL cursor. How an Explicit cursor works? The process of working with an explicit cursor consists of the following steps: 1. Declaring the cursor. This initializes the cursor into memory. 2. Opening the cursor. The declared cursor is opened, and memory is allotted. 3. Fetching the cursor. The declared and opened cursor can now retrieve data. 4. Closing the cursor. The declared, opened, and fetched cursor must be closed t o release the memory allocation. What are Explicit Cursor attributes %NOTFOUND cursor_name%NOTFOUND A Boolean attribute that returns TRUE if the previous FETCH did not return a row and FALSE if it did. %FOUND cursor_name%FOUND A Boolean attribute that returns TRUE if the previous FETCH returned a row and FALSE if it did not. %ROWCOUNT cursor_name%ROWCOUNT The number of records fetched from a cursor at that point in time. %ISOPEN cursor_name%ISOPEN A Boolean attribute that returns TRUE if the cursor is open and FALSE if it is not. Answer any three PL/SQL Exceptions? Too_many_rows, No_Data_Found, Value_Error, Zero_Error, Others What are PL/SQL Cursor Exceptions? Cursor_Already_Open, Invalid_Cursor What is the maximum number of triggers, can apply to a single table? 12 triggers. What is a mutating table error and how can you get around it? Oracle SQL & PL/SQL: SQL PL/SQL Interview Questions http://sql-plsql.blogspot.co m/2007/04/sql-plsql-interview-questions.html 3 of 5 10-10-11 6:42 AM Interview Questions SQL PL/SQL Interview Questions SQL PL/SQL Interview Questions SQL

PL/SQL Interview Questions SQL PL/SQL Interview Questions SQL PL/SQL Interview Questions SQL PL/SQL Interview Questions SQL PL/SQL Interview Questions SQL PL/SQL Interview Questions SQL PL/SQL Interview 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 t ables so the database is selecting from one while updating the other. What packages (if any) has Oracle provided for use by developers? 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, gre at, but not really what was asked. Describe the use of PL/SQL tables 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 the y will be able to be of the %ROWTYPE designation, or RECORD. 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. 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? OPEN then FETCH then LOOP followed by the exit when. If not specified in this or der will result in the final return being done twice because of the way the %NOTFOUN D is handled by PL/SQL. What are SQLCODE and SQLERRM and why are they important for PL/SQL developers?

SQLCODE returns the value of the error number for the last error encountered. Th e SQLERRM returns the actual error message for the last error encountered. They ca n be used in exception handling to report, or, store in an error log table, the er ror that occurred in the code. These are especially useful for the WHEN OTHERS exception. How can you find within a PL/SQL block, if a cursor is open? Use the %ISOPEN cursor status variable. How can you generate debugging output from PL/SQL? 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. What are the types of triggers? 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. How can I define a two-dimensional array of numbers in PL/SQL? Although PL/SQL does not natively support the declaration and manipulation of Oracle SQL & PL/SQL: SQL PL/SQL Interview Questions http://sql-plsql.blogspot.co m/2007/04/sql-plsql-interview-questions.html 4 of 5 10-10-11 6:42 AM Quemsutilotindsimensional arrays, you can emulate these structures using nested collection definitions, which were first supported in Oracle9i Database Release 1. Here is a brief example to get you started and introduce you to some of the challenges you may encounter as you use collections in this way. First, create a collection of associative arrays. CREATE OR REPLACE PACKAGE twodim_aa IS TYPE data_t IS TABLE OF NUMBER INDEX BY PLS_INTEGER; TYPE array_t IS TABLE OF data_t INDEX BY PLS_INTEGER; END twodim_aa; / The first, inner collection data_t contains the data for each cell in the two-dimensional array. Each row in the outer collection array_t contains a collection of the first type. Now declare a variable based on that outer collection type array_t , which will serve as a two-dimensional array. In the following script, I declare such a coll ection DECLARE l_2d_grid twodim_aa.array_t; and then assign values to three cells: (1,1), (1,2), and (200,206). Notice that t he syntax is different from that used in traditional array cell specification, name ly: (1)(1), (1)(2), and (200)(206). Also, since I am using associative arrays to define my two-dimensional array, I do not have to specify a size for this two-dimensional array. DECLARE l_2d_grid twodim_aa.array_t; BEGIN l_2d_grid (1) (1) := 100; l_2d_grid (1) (2) := 120;

l_2d_grid (200) (206) := 200; IF l_2d_grid (1)(2) source of above question: http://www.oracle.com/technology/oramag/oracle/06-jan/ o16plsql.html Home Oracle SQL & PL/SQL: SQL PL/SQL Interview Questions http://sql-plsql.blogspot.co m/2007/04/sql-plsql-interview-questions.html 5 of 5 10-10-11 6:42 AM

You might also like