Programming in PL/SQL (Basic Concepts)

Imporove your PL/SQL Skills

25 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

How many sections or parts are there in a PL/SQL program?

  1. 1
  2. 2
  3. 3
  4. 4
Question 2 Multiple Choice (Single Answer)

A group of related data items stored in fields, each with its own name and datatype, is called

  1. varray
  2. nested table
  3. record
  4. index-by tables
Question 3 Multiple Choice (Single Answer)

Which of the following is NOT a valid loop in PL/SQL?

  1. For loop.. end loop
  2. loop..end loop
  3. While loop.. end loop
  4. Do while loop..end loop
Question 4 Multiple Choice (Single Answer)

When a 'Select' command is written inside a PL/SQL program, the ____ keyword must be included in it.

  1. where
  2. in
  3. group by
  4. into
Question 5 Multiple Choice (Single Answer)

Which of the following is NOT a valid cursor attribute?

  1. %ISOPEN
    <!--?xml:namespace prefix = o /--><o:p></o:p>
    <o:p></o:p>
  2. %EXISTS
  3. %FOUND
    <o:p></o:p>
  4. %ROWCOUNT
Question 6 Multiple Choice (Single Answer)

Which of the following is a schema object that groups logically related PL/SQL types, items and sub-programs?

  1. Trigger
    <!--?xml:namespace prefix = o /--><o:p></o:p>
  2. Procedure
    <o:p></o:p>
  3. Function
    <o:p></o:p>
  4. Package
    <o:p></o:p>
Question 7 Multiple Choice (Single Answer)

For which of the following SQL statements can a trigger not be written?

  1. Alter
  2. Update
  3. Delete
  4. Insert
Question 8 Multiple Choice (Single Answer)

In PL/SQL, which of the following is the correct syntax of the 'if-else' statement?

  1. If condition then
    statements
    elseif condition then
    statements
    else
    statements
    end if;
  2. if condition
    statements
    elseif condition
    statements
    else
    statements
    end if;
  3. if condition then
    statements
    elif condition then
    statements
    else
    statements
    end if;
  4. if condition
    statements
    elsif condition
    statements
    else
    statements
    endif;
Question 9 Multiple Choice (Single Answer)

Which of the following is NOT a correct way of passing parameters to a function or a procedure in PL/SQL?

  1. IN
  2. OUT
  3. INOUT
  4. OUTIN
Question 10 Multiple Choice (Single Answer)

Which named exception is thrown when an attempt is made to open a cursor that is already open?

  1. INVALID_CURSOR
  2. OPEN_CURSOR
  3. CURSOR_ALREADY_OPEN
  4. CURSOR_IS_OPEN
Question 11 Multiple Choice (Single Answer)

Which of the following is the correct difference between a procedure and a function?

  1. Procedure can be called from SQL prompt, while function cannot be called from SQL prompt.
  2. Function can return a value, while procedure cannot return any value.
  3. Functions can have arguments, while procedure cannot have arguments.
  4. Function can call procedures while procedure cannot call functions.
Question 12 Multiple Choice (Single Answer)

Which of the following statements is FALSE about packages?

  1. Packages are made up of two components: specification and body
  2. The package body contains the actual code.
  3. The package specification contains the actual code.
  4. Packages encapsulate related procedures, functions, etc. into one self-contained unit.
Question 13 Multiple Choice (Single Answer)

Which of the following statements is FALSE regarding triggers?

  1. A trigger can be written for handling updates of a particular column.
  2. A trigger can be run either before or after the execution of an SQL statement.
  3. A trigger cannot be written on a view.
  4. A trigger cannot contains a condition.
Question 14 Multiple Choice (Single Answer)

Which of the following is the correct method of declaring a constant in PL/SQL?

  1. Data constant number (3)=10
  2. Data constant number (3) := 10;
  3. Data constant number (3);
  4. Constant Data number (3) := 10;
Question 15 Multiple Choice (Single Answer)

Which of the following keywords is NOT present in a 'function declaration'?

  1. Declare
  2. Begin
  3. Return
  4. Exception
Question 16 Multiple Choice (Single Answer)

Which of the following is NOT a difference between SQL and PL/SQL ?

  1. SQL is declarative, while PL/SQL is procedural.
  2. SQL is used to write queries, whereas PL/SQL is used to code programs.
  3. SQL can be embedded within PL/SQL but a PL/SQL statement cannot be embedded in SQL.
  4. PL/SQL executes one statement at a time, whereas SQL is used to write a code block.
Question 17 Multiple Choice (Single Answer)

In a PL/SQL 'case' statement, if all the given conditions are false, the statements written in the ____ block are executed.

  1. default
  2. else
  3. case
  4. otherwise
Question 18 Multiple Choice (Single Answer)

Which of the following is the correct method of handling exceptions in the 'Exception' section?

  1. If exception then
    exception handling statements
  2. If raised_exception then
    exception handling statements
  3. When exception then
    exception handling statements
  4. When raised_exception then
    exception handling statements
Question 19 Multiple Choice (Single Answer)

In a PL/SQL program, to declare a variable with the same data type as a column of a table (anchored declaration), the correct syntax will be

  1. Varname tablename.colname%rowtype
  2. Varname tablename.colname%istype
  3. Varname tablename.colname%totype
  4. Varname tablename.colname%type
Question 20 Multiple Choice (Single Answer)

Which of the following is NOT an advantage of subprograms (procedures and functions)?

  1. Modularity
  2. Reusability
  3. Abstraction
  4. Inheritance
Question 21 Multiple Choice (Single Answer)

With reference to OLD and NEW pseudorecords, which of the following statements is FALSE ?

  1. For an INSERT trigger, OLD contains no value and NEW contains new values.
  2. For an ALTER trigger, OLD contains the old values, and NEW contains the new values.
  3. For an UPDATE trigger, OLD contains the old values, and NEW contains the new values.
  4. For a DELETE trigger, OLD contains old values, and NEW contains no value.
Question 22 Multiple Choice (Single Answer)

Which of the following statements is FALSE regarding 'Parameters in Cursor' (Parameterized Cursor)?

  1. The mode of a parameter can be both IN and OUT.
  2. A cursor parameter can be assigned a default value.
  3. The scope of the cursor parameter is local to the cursor.
  4. We can only specify the datatype of the parameter, not its length.
Question 23 Multiple Choice (Single Answer)

Which of the following statements is FALSE about 'Implicit Cursors'?

  1. Oracle performs the open, fetches, and close for you automatically.
  2. It is less efficient than an explicit cursor.
  3. It is less vulnerable to data errors.
  4. It gives you less programmatic control.
Question 24 Multiple Choice (Single Answer)

Which of the following statements is FALSE regarding variable names?

  1. Variable names must start with a letter.
  2. Variable names cannot contain a '$' sign.
  3. Variable names cannot contain spaces.
  4. Variable name should be a maximum of 30 characters in length.
Question 25 Multiple Choice (Single Answer)

Which line in the above code has an error?

 declare
            no number;
            sq number;
begin
            no:=&number; --Line 1
            if no>10000 then -- Line 2
                        dbms_output.put_line('Too large value'); -- Line 3
            else -- Line 4
                        sq=no*no; -- Line 5
                        dbms_output.put_line(\\\\\\'Square of \\\\\\' || no || \\\\\\' is \\\\\\' || sq); -- Line 6
            end if; -- Line 7
end;
/

  1. Line 1
  2. Line 2
  3. Line 5
  4. Line 6