Showing posts with label advanced plsql interview question. Show all posts
Showing posts with label advanced plsql interview question. Show all posts

Monday, May 29, 2017

Oracle Interview Questions and Answers - SQL Queries and Database

1. What is oracle database ?
Oracle Database is a relational database management system (RDBMS) which is used to store and retrieve the large amounts of data. Oracle Database had physical and logical structures. Logical structures and physical structures are separated from each other
2. Explain oracle grid architecture?
Grid computing is a information technology architecture that provides lower cost enterprise information systems. Using grid computing, independent hardware, and software components can be connected and rejoined on demand to meet the changing needs of businesses. It also enables the use of smaller individual hardware components.
3. What is the difference between large dedicated server and oracle grid?
Large dedicated server:
  • It has expensive costly components.
  • High incremental costs.
  • It has single point of failure.
  • Enterprise service at higher cost.
Oracle Grid:
  • It has low cost modular components.
  • Low incremental costs.
  • It has no single point of failure.
  • Enterprise service at low cost.
4. What are the computing components of oracle grid?
The computing componenets of oracle grid are:
  • Oracle Enterprise Manager and Grid Control
  • Oracle 10g Database and Real Application Clusters.
  • ASM Storage Grid.
5. What is server virtualization?
Oracle Real Application Clusters 10g (RAC) enables a single database to run across multiple clustered nodes in a grid, pooling the processing resources of several standard machines.

6. What is storage virtualization?
The Oracle Automatic Storage Management (ASM) is a feature of Oracle Database 10g which provides a virtual layer between the database and storage so that group of disks can be treated as a single disk group and disks can be dynamically added or removed while keeping databases online.
Also Read Basic to Advanced Oracle SQL Query Interview Question and Answers
7. What is Grid Management feature?
The Grid Management feature of Oracle Enterprise Manager 10g provides a single console to manage multiple systems together as a logical group.
8. When oracle allocates an SGA?
When Oracle starts, it reads the initialization parameter file to determine the values of initialization parameters. After this, it allocates an SGA and creates background processes.
9. What is an oracle instance?
When you start, the database instance comes into picture into system memory. Combination of the SGA and the Oracle processes is called an Oracle instance.
10. What are the several tools for interacting with the oracle database using sql?
There are several tools for interfacing with the database using SQL:
  • Oracle SQL*Plus and iSQL*Plus 
  • Oracle Forms, Reports, and Discoverer
  • Oracle Enterprise Manager 
  • Third-party tools
11. How oracle works?
  • An instance has started on the database server.
  • A client established a connection to the server, using the proper Oracle Net Services driver.
  • The server creates a dedicated server process on behalf of the user process.
  • The user executes SQL statement and commits the transaction.
  • The server process receives the statement and checks for any shared SQL area that contains a similar SQL.
  • The server process retrieves data from datafile (table) or SGA.
  • The server process modifies data in the SGA area. The DBWn process writes modified blocks permanently to disk. The LGWR process records the transaction in the redo log file.
  • The server process sends a message to the application.

12. What contains oracle physical database structure?
It contains
  • Datafiles
  • Control Files
  • Redo Log Files
  • Archive Log Files
  • Parameter Files
  • Alert and Trace Log Files
  • Backup Files
13. What is a Tablespace?
Oracle use Tablespace for logical data Storage. Physically, data will get stored in Datafiles. Datafiles will be connected to tablespace. A tablespace can have multiple datafiles. A tablespace can have objects from different schema's and a schema can have multiple tablespace's. Database creates "SYSTEM tablespace" by default during database creation. It contains read only data dictionary tables which contains the information about the database. 
14. What is a Control File ?
Control file is a binary file which stores Database name, associated data files, redo files, DB creation time and current log sequence number. Without control file database cannot be started and can hamper data recovery.
15. What are data blocks?
Oracle stores data in data blocks also called as logical blocks, Oracle blocks or pages. A data block represents specific number of bytes of space on disk.
16. What is an extent?
An extent is a specific number of consecutive data blocks allocated for storing a specific type of information.
17. What is a segment?
A segment is a group of extents, each of which has been allocated for a specific data structure and all of which are stored in the same table-space.
18. What is Rollback Segment ? 
Database contain one or more Rollback Segments to roll back transactions and data recovery.
19. What are the different type of Segments ? 
Data Segment(for storing User Data), Index Segment (for storing index), Rollback Segment and Temporary Segment.
20. What is an oracle schema?
A user account and its associated data including tables, views, indexes, clusters, sequences,procedures, functions, triggers,packages and database links is known as Oracle schema. System, SCOTT etc are default schema's. We can create a new Schema/User. But we can't drop default database schema's.
21. When and how oracle database creates a schema?
Oracle Database automatically creates a schema when you create a user.
22. What is a view?
A view is a tailored presentation of the data contained in one or more tables or other views. A view is output of a query and treats it as a table. Therefore, a view can be thought of as a stored query or a virtual table. A view is not assigned any storage space, nor does a view actually contain data.
23. How views are used?
  • It provides security by restricting access to a predetermined set of rows or columns of a table. It hides data complexity. It simplifies statements for the user.
  • An example would be the views, which allow users to select data from multiple tables without actually knowing how to perform a join.
  • It presents the data in a different perspective from that of the base table. It isolate applications from changes in definitions of base tables. It saves complex queries.
24. What are materialized views?
These are schema objects that are used to summarize, compute, replicate, and distribute data. They can be used in various environments for computation such as data warehousing, decision support, and distributed or mobile computing and it also provides local access to data rather than accessing from remote sites. In data warehouses, MVs are used to compute and store aggregated data.

Thursday, October 15, 2015

New PL SQL Interview Questions - Entry Level Interview Questions for Database Developers

SQL PL/SQL Question 1

How to display row number with records?
Select rownum, ename from emp;

SQL PL/SQL Question 2

How to view version information in Oracle?
Select banner from v$version;

SQL PL/SQL Question 3

How to find the second highest salary in emp table?
select min(sal) from emp a
where 1 = (select count(*) from emp b where a.sal <>

SQL PL/SQL Question 4

How to delete the duplicate rows from a table?
create table t1 ( col1 int, col2 int, col3 char(1) );
insert into t1 values(1,50, ‘a’);
insert into t1 values(1,50, ‘b’);
insert into t1 values(1,89, ‘x’);
insert into t1 values(1,89, ‘y’);
insert into t1 values(1,89, ‘z’);
select * from t1;

Col1Col2Col2
150a
150b
289x
289y
289z

delete from T1
where rowid <> ( select max(rowid)
from t1 b
where b.col1 = t1.col1
and b.col2 = t1.col2 ) 3 rows deleted.

select * from t1;
Col1Col2Col2
150a
289z
will do it.

SQL PL/SQL Question 5

How to select a row using indexes?
You have to specify the indexed columns in the WHERE clause of query.

SQL PL/SQL Question 6

How to select the first 5 characters of FIRSTNAME column of EMP table?
select substr(firstname,1,5) from emp

SQL PL/SQL Question 7

How to concatenate the firstname and lastname from emp table?
select firstname ‘ ‘ lastname from emp

SQL PL/SQL Question 8

What's the difference between a primary key and a unique key?
Primary key does not allow nulls, Unique key allow nulls.

SQL PL/SQL Question 9

What is a self join?
A self join joins a table to itself.

Example

SELECT a.last_name Employee, b.last_name Manager
FROM employees a, employees b
WHERE b.employee_id = a.manager_id;

SQL PL/SQL Question 10

What is a transaction and ACID?
Transaction - A transaction is a logical unit of work. It must be commited or rolled back.
ACID - Atomicity, Consistency, Isolation and Duralbility, these are properties of a transaction.

SQL PL/SQL Question 11

How to add a column to a table?
alter table t1 add sal number;
alter table t1 add middle_name varchar(20);

SQL PL/SQL Question 12

Is it possible for a table to have more than one foreign key ?
A table can have any number of foreign keys. It can have only one primary key .

SQl PL/SQL Question 13

How to display number value in words?
SQL> select sal, (to_char(to_date(sal,'j'), 'jsp')) from emp;

SQL PL/SQL Question 14

What is candidate key, alternate key, composite key.
Candidate Key A candidate key is one that can identify each row of a table uniquely. Generally a candidate key becomes the primary key of the table.
Alternate KeyIf the table has more than one candidate key, one of them will become the primary key, and the rest are called alternate keys.
Composite Key: - A key formed by combining at least two or more columns is called composite key.

SQL PL/SQL Question 15

What's the difference between DELETE TABLE and TRUNCATE TABLE commands? Explain drop command.
Both Delete and Truncate will leave the structure of the table. Drop will remove the structure also.

  1. Example

    If tablename is T1.
    To remove all the rows from a table t1.
    Delete t1
    Truncate table t1
    Drop table t1.
  2. Truncate is fast as compared to Delete. DELETE will generate undo information, in case of rollback, but TRUNCATE will not.

  3. Full Table scan and index fast scan read data blocks up to high water mark and truncate resets high water mark but delete does not.So full table scan after Delete will not improve but after truncate it will be fast.
  4. Delete is DML. Because truncate is a DDL, it performs implicit commit. You cannot rollback a truncate. Any uncommitted DML changes will also be committed with the TRUNCATE.
  5. You cannot specify a WHERE clause in the TRUNCATE statement, but you can specify that in Delete.
  6. When you truncate a table the storage for the table and all the indexes can be reset back to its initial size,but a Delete will never shrink the size of the a table or its indexes.
About Dropping
Dropping a table removes the data and definition of the table. The indexes, constraints, triggers, and privileges on the table are also dropped. The action of dropping a table cannot be undone. The views, materialized views or other stored programs that reference the table are not dropped but they are marked as invalid.

SQL PL/SQL Question 16

Explain the difference between a FUNCTION, PROCEDURE and PACKAGE.
Procedures and functions are stored in compiled form in database.
Functions take zero or more parameters and return a value. Procedures take zero or more parameters and return no values.
Both functions and procedures can take or return zero or more values through their parameter lists.
Another difference between procedures and functions, other than the return value, is how they are called. Procedures are called as stand-alone executable statements:
my_procedure(parameter1,parameter2...);
Functions can be called anywhere in an valid expression :
e.g
1) IF (tell_salary(empno) < 500 ) THEN … 2) var1 := tell_salary(empno); 3) DECLARE var1 NUMBER DEFAULT tell_salary(empno); BEGIN …
Packages contain function , procedures and other data structures.
There are a number of differences between packaged and non-packaged PL/SQL programs. Package The data in package is persistent for the duration of the user’s session.The data in package thus exists across commits in the session.
If you grant execute privilege on a package, it is for all functions and procedures and data structures in the package specification. You cannot grant privileges on only one procedure or function within a package. You can overload procedures and functions within a package, declaring multiple programs with the same name. The correct program to be called is decided at runtime, based on the number or datatypes of the parameters.

SQL PL/SQL Question 17

Describe the use of %ROWTYPE and %TYPE in PL/SQL
%ROWTYPE associates a variable to an entire table row.
The %TYPE associates a variable with a single column type.

SQ PL/SQL Question 18

What are SQLCODE and SQLERRM and why are they important for PL/SQL developers?
SQLCODE returns the current database error number. These error numbers are all negative, except NO_DATA_FOUND, which returns +100.
SQLERRM returns the textual error message.. These are used in exception handling.

SQL PL/SQL Question 19

How can you find within a PL/SQL block, if a cursor is open?
By the Use of %ISOPEN cursor variable.

SQL PL/SQL Question 20

How do you debug output from PL/SQL?
By the use the DBMS_OUTPUT package.
By the use of SHOW ERROR command, but this only shows errors.
The package UTL_FILE can also be used.

SQL PL/SQL Question 21

What are the types of triggers?
  • Use Row and Statement Triggers
  • Use INSTEAD OF Triggers

    SQL PL/SQL Question 22

    Explain the usage of WHERE CURRENT OF clause in cursors ?
    It refers to the latest row fetched from a cursor in an update and delete statement.

    SQL PL/SQL Question 23

    Name the tables where characteristics of Package, procedure and functions are stored ?
    User_objects, User_Source and User_error.

    SQL PL/SQL Question 24

    What are two parts of package ?
    They consist of package specification, which contains the function headers, procedure headers, and externally visible data structures. The package also contains a package body, which contains the declaration, executable, and exception handling sections of all the bundled procedures and functions.

    SQL PL/SQL Question 25

    What are two virtual tables available during database trigger execution ?
    The table columns are referred as OLD.column_name and NEW.column_name.
    For INSERT only TRIGGERS NEW.column_name values ARE only available.
    For UPDATE only TRIGERS OLD.column_name NEW.column_name values ARE only available.
    For DELETE only TRIGGERS OLD.column_name values ARE only available.v

    SQL PL/SQL Question 26

    What is Overloading of procedures ?
    REPEATING OF SAME PROCEDURE NAME WITH DIFERENT PARAMETER LIST.

    SQL PL/SQL Question 27

    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.

    SQL PL/SQL Question 28

    Is it possible to use Transaction control Statements such a ROLLBACK or COMMIT in Database Trigger ? Why ?
    It is not possible.,because of the side effect to transactions. You can use them indirectly by calling procedures or functions .

    SQL PL/SQL Question 29

    What are the modes of parameters that can be passed to a procedure ?
    IN, OUT, IN-OUT parameters.
  • Sunday, November 16, 2014

    PL SQl Interview Questions - Basics to Advanced Interview Questions

    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.

    2.     What is the basic structure of PL/SQL?
        PL/SQL uses block structure as its basic structure. Anonymous blocks or nested blocks can be used in PL/SQL.

    3.     What are the components of a PL/SQL block?
        A set of related declarations and procedural statements is called block.

    4.     What are the components of a PL/SQL Block?
        Declarative part, Executable part and Execption part.

    5.     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.

    6.     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.

    7.     What is difference between % ROWTYPE and TYPE RECORD ?
        % ROWTYPE is to be used whenever query returns a entire row of a table or view.
    TYPE rec RECORD is to be used whenever query returns columns of different table or views and variables.

    E.g. TYPE r_emp is RECORD (eno emp.empno% type,ename emp ename %type );
    e_rec emp% ROWTYPE
    Cursor c1 is select empno,deptno from emp;
    e_rec c1 %ROWTYPE.

    8.     What is PL/SQL table?
        Objects of type TABLE are called "PL/SQL tables", which are modelled 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.

    9.     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.

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

    11.     What are the PL/SQL Statements used in cursor processing?
          DECLARE CURSOR cursor name, OPEN cursor name, FETCH cursor name INTO <variable list> or Record types, CLOSE cursor name.

    12.     What are the cursor attributes used in PL/SQL?
           %ISOPEN - to check whether cursor is open or not
    % ROWCOUNT - number of rows featched/updated/deleted.
    % FOUND - to check whether cursor has fetched any row. True if rows are featched.
    % NOT FOUND - to check whether cursor has featched any row. True if no rows are featched.
    These attributes are proceded with SQL for Implict Cursors and with Cursor name for Explict Cursors.

    13.     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;

    14.     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.

    15.     Explain the usage of WHERE CURRENT OF clause in cursors ?
        WHERE CURRENT OF clause in an UPDATE,DELETE statement refers to the latest row fetched from a cursor.

    16.     What is a database trigger ? Name some usages of database trigger ?
        Database trigger is stored PL/SQL program unit associated with a specific database table. Usages are Audit data modificateions, Log events transparently, Enforce complex business rules Derive column values automatically, Implement complex security authorizations. Maintain replicate tables.

    17.     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 retruned boolean value.

    18.     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.

    19.     What are two virtual tables available during database trigger execution?
          The table columns are referred as OLD.column_name and NEW.column_name.
    For triggers related to INSERT only NEW.column_name values only available.
    For triggers related to UPDATE only OLD.column_name NEW.column_name values only available.
    For triggers related to DELETE only OLD.column_name values only available.

    20.     What happens if a procedure that updates a column of table X is called in a database trigger of the same table?
        Mutation of table occurs.

    21.     Write the order of precedence for validation of a column in a table ?
        I. done using Database triggers.
    ii. done using Integarity Constraints.

    22.     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 execptions 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.

    23.     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)

    24.     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.

    25.     What are the return values of functions SQLCODE and SQLERRM?
        SQLCODE returns the latest code of the error that has occured.
    SQLERRM returns the relevant error message of the SQLCODE.

    26.     Where the Pre_defined_exceptions are stored?
        In the standard package.
    Procedures, Functions & Packages;

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

    30.     What is difference between a PROCEDURE & FUNCTION?
        A FUNCTION is alway returns a value using the return statement.
    A PROCEDURE may return one or more values through parameters or may not return at all.

    31.     What are advantages of Stored Procedures?
        Extensibility,Modularity, Reusability, Maintainability and one time compilation.

    32.     What are the modes of parameters that can be passed to a procedure?
        IN,OUT,IN-OUT parameters.

    33.     What are the two parts of a procedure?
        Procedure Specification and Procedure Body.

    34.     Give the structure of the procedure?
          PROCEDURE name (parameter list.....)
    is
    local variable declarations

    BEGIN
    Executable statements.
    Exception.
    exception handlers

    end;

    35.     Give the structure of the function?
          FUNCTION name (argument list .....) Return datatype is
    local variable declarations
    Begin
    executable statements
    Exception
    execution handlers
    End;

    36.     Explain how procedures and functions are called in a PL/SQL block ?
          Function is called as part of an expression.
    sal := calculate_sal ('a822');
    procedure is called as a PL/SQL statement
    calculate_bonus ('A822');

    37.     What is Overloading of procedures?
          The Same procedure name is repeated with parameters of different datatypes and parameters in different positions, varying number of parameters is called overloading of procedures.

    e.g. DBMS_OUTPUT put_line

    38.     What is a package? What are the advantages of packages?
          Package is a database object that groups logically related procedures.
    The advantages of packages are Modularity, Easier Applicaton Design, and Information.
    Hiding,. Reusability and Better Performance.

    39.     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.

    40.     What is difference between a Cursor declared in a procedure and Cursor declared in a package specification?
          A cursor declared in a package specification is global and can be accessed by other procedures or procedures in a package.
    A cursor declared in a procedure is local to the procedure that can not be accessed by other procedures.

    41.     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.

    42.     Name the tables where characteristics of Package, procedure and functions are stored?
        User_objects, User_Source and User_error.
     

    Wednesday, August 6, 2014

    PL/SQL Advanced Interview Questions

    PL/SQL Advanced Interview Questions

    1. Which of the following statements is true about implicit cursors?
      1. Implicit cursors are used for SQL statements that are not named.
      2. Developers should use implicit cursors with great care.
      3. Implicit cursors are used in cursor for loops to handle data processing.
      4. Implicit cursors are no longer a feature in Oracle.

    2. Which of the following is not a feature of a cursor FOR loop?
      1. Record type declaration.
      2. Opening and parsing of SQL statements.
      3. Fetches records from cursor.
      4. Requires exit condition to be defined.
    3. A developer would like to use referential datatype declaration on a variable. The variable name is EMPLOYEE_LASTNAME, and the corresponding table and column is EMPLOYEE, and LNAME, respectively. How would the developer define this variable using referential datatypes?
      1. Use employee.lname%type.
      2. Use employee.lname%rowtype.
      3. Look up datatype for EMPLOYEE column on LASTNAME table and use that.
      4. Declare it to be type LONG.
    4. Which three of the following are implicit cursor attributes?
      1. %found
      2. %too_many_rows
      3. %notfound
      4. %rowcount
      5. %rowtype
    5. If left out, which of the following would cause an infinite loop to occur in a simple loop?
      1. LOOP
      2. END LOOP
      3. IF-THEN
      4. EXIT
    6. Which line in the following statement will produce an error?
      1. cursor action_cursor is
      2. select name, rate, action
      3. into action_record
      4. from action_table;
      5. There are no errors in this statement.
    7. The command used to open a CURSOR FOR loop is
      1. open
      2. fetch
      3. parse
      4. None, cursor for loops handle cursor opening implicitly.
    8. What happens when rows are found using a FETCH statement
      1. It causes the cursor to close
      2. It causes the cursor to open
      3. It loads the current row values into variables
      4. It creates the variables to hold the current row values
    9. Read the following code:
      CREATE OR REPLACE PROCEDURE find_cpt
      (v_movie_id {Argument Mode} NUMBER, v_cost_per_ticket {argument mode} NUMBER)
      IS
      BEGIN
        IF v_cost_per_ticket  > 8.5 THEN
      SELECT  cost_per_ticket
      INTO            v_cost_per_ticket
      FROM            gross_receipt
      WHERE   movie_id = v_movie_id;
        END IF;
      END;
      
      Which mode should be used for V_COST_PER_TICKET?
      1. IN
      2. OUT
      3. RETURN
      4. IN OUT
    10. Read the following code:
      CREATE OR REPLACE TRIGGER update_show_gross
            {trigger information}
           BEGIN
            {additional code}
           END;
      
      The trigger code should only execute when the column, COST_PER_TICKET, is greater than $3. Which trigger information will you add?
      1. WHEN (new.cost_per_ticket > 3.75)
      2. WHEN (:new.cost_per_ticket > 3.75
      3. WHERE (new.cost_per_ticket > 3.75)
      4. WHERE (:new.cost_per_ticket > 3.75)
    11. What is the maximum number of handlers processed before the PL/SQL block is exited when an exception occurs?
      1. Only one
      2. All that apply
      3. All referenced
      4. None
    12. For which trigger timing can you reference the NEW and OLD qualifiers?
      1. Statement and Row
      2. Statement only
      3. Row only
      4. Oracle Forms trigger
    13. Read the following code:
      CREATE OR REPLACE FUNCTION get_budget(v_studio_id IN NUMBER)
      RETURN number IS
      
      v_yearly_budget NUMBER;
      
      BEGIN
             SELECT  yearly_budget
             INTO            v_yearly_budget
             FROM            studio
             WHERE   id = v_studio_id;
      
             RETURN v_yearly_budget;
      END;
      
      Which set of statements will successfully invoke this function within SQL*Plus?
      1. VARIABLE g_yearly_budget NUMBER
        EXECUTE g_yearly_budget := GET_BUDGET(11);
      2. VARIABLE g_yearly_budget NUMBER
        EXECUTE :g_yearly_budget := GET_BUDGET(11);
      3. VARIABLE :g_yearly_budget NUMBER
        EXECUTE :g_yearly_budget := GET_BUDGET(11);
      4. VARIABLE g_yearly_budget NUMBER
        :g_yearly_budget := GET_BUDGET(11);
    14. CREATE OR REPLACE PROCEDURE update_theater
      (v_name IN VARCHAR v_theater_id IN NUMBER) IS
      BEGIN
             UPDATE  theater
             SET             name = v_name
             WHERE   id = v_theater_id;
      END update_theater;
      
      When invoking this procedure, you encounter the error:
      ORA-000: Unique constraint(SCOTT.THEATER_NAME_UK) violated.
      How should you modify the function to handle this error?
      1. An user defined exception must be declared and associated with the error code and handled in the EXCEPTION section.
      2. Handle the error in EXCEPTION section by referencing the error code directly.
      3. Handle the error in the EXCEPTION section by referencing the UNIQUE_ERROR predefined exception.
      4. Check for success by checking the value of SQL%FOUND immediately after the UPDATE statement.
    15. Read the following code:
      CREATE OR REPLACE PROCEDURE calculate_budget IS
      v_budget        studio.yearly_budget%TYPE;
      BEGIN
             v_budget := get_budget(11);
             IF v_budget < 30000
        THEN
                     set_budget(11,30000000);
             END IF;
      END;
      
      You are about to add an argument to CALCULATE_BUDGET. What effect will this have?
      1. The GET_BUDGET function will be marked invalid and must be recompiled before the next execution.
      2. The SET_BUDGET function will be marked invalid and must be recompiled before the next execution.
      3. Only the CALCULATE_BUDGET procedure needs to be recompiled.
      4. All three procedures are marked invalid and must be recompiled.
    16. Which procedure can be used to create a customized error message?
      1. RAISE_ERROR
      2. SQLERRM
      3. RAISE_APPLICATION_ERROR
      4. RAISE_SERVER_ERROR
    17. The CHECK_THEATER trigger of the THEATER table has been disabled. Which command can you issue to enable this trigger?
      1. ALTER TRIGGER check_theater ENABLE;
      2. ENABLE TRIGGER check_theater;
      3. ALTER TABLE check_theater ENABLE check_theater;
      4. ENABLE check_theater;
    18. Examine this database trigger
      CREATE OR REPLACE TRIGGER prevent_gross_modification
      {additional trigger information}
      BEGIN
             IF TO_CHAR(sysdate, DY) = MON
       THEN
       RAISE_APPLICATION_ERROR(-20000,Gross receipts cannot be deleted on Monday);
             END IF;
      END;
      
      This trigger must fire before each DELETE of the GROSS_RECEIPT table. It should fire only once for the entire DELETE statement. What additional information must you add?
      1. BEFORE DELETE ON gross_receipt
      2. AFTER DELETE ON gross_receipt
      3. BEFORE (gross_receipt DELETE)
      4. FOR EACH ROW DELETED FROM gross_receipt
    19. Examine this function:
      CREATE OR REPLACE FUNCTION set_budget
      (v_studio_id IN NUMBER, v_new_budget IN NUMBER) IS
      BEGIN
             UPDATE  studio
             SET             yearly_budget = v_new_budget
             WHERE   id = v_studio_id;
      
             IF SQL%FOUND THEN
                     RETURN TRUEl;
             ELSE
                     RETURN FALSE;
             END IF;
      
             COMMIT;
      END;
      
      Which code must be added to successfully compile this function?
      1. Add RETURN right before the IS keyword.
      2. Add RETURN number right before the IS keyword.
      3. Add RETURN boolean right after the IS keyword.
      4. Add RETURN boolean right before the IS keyword.
    20. Under which circumstance must you recompile the package body after recompiling the package specification?
      1. Altering the argument list of one of the package constructs
      2. Any change made to one of the package constructs
      3. Any SQL statement change made to one of the package constructs
      4. Removing a local variable from the DECLARE section of one of the package constructs
    21. Procedure and Functions are explicitly executed. This is different from a database trigger. When is a database trigger executed?
      1. When the transaction is committed
      2. During the data manipulation statement
      3. When an Oracle supplied package references the trigger
      4. During a data manipulation statement and when the transaction is committed
    22. Which Oracle supplied package can you use to output values and messages from database triggers, stored procedures and functions within SQL*Plus?
      1. DBMS_DISPLAY
      2. DBMS_OUTPUT
      3. DBMS_LIST
      4. DBMS_DESCRIBE
    23. What occurs if a procedure or function terminates with failure without being handled?
      1. Any DML statements issued by the construct are still pending and can be committed or rolled back.
      2. Any DML statements issued by the construct are committed
      3. Unless a GOTO statement is used to continue processing within the BEGIN section, the construct terminates.
      4. The construct rolls back any DML statements issued and returns the unhandled exception to the calling environment.
    24. Examine this code
      BEGIN
             theater_pck.v_total_seats_sold_overall := theater_pck.get_total_for_year;
      END;
      
      For this code to be successful, what must be true?
      1. Both the V_TOTAL_SEATS_SOLD_OVERALL variable and the GET_TOTAL_FOR_YEAR function must exist only in the body of the THEATER_PCK package.
      2. Only the GET_TOTAL_FOR_YEAR variable must exist in the specification of the THEATER_PCK package.
      3. Only the V_TOTAL_SEATS_SOLD_OVERALL variable must exist in the specification of the THEATER_PCK package.
      4. Both the V_TOTAL_SEATS_SOLD_OVERALL variable and the GET_TOTAL_FOR_YEAR function must exist in the specification of the THEATER_PCK package.
    25. A stored function must return a value based on conditions that are determined at runtime. Therefore, the SELECT statement cannot be hard-coded and must be created dynamically when the function is executed. Which Oracle supplied package will enable this feature?
      1. DBMS_DDL
      2. DBMS_DML
      3. DBMS_SYN
      4. DBMS_SQL