0% found this document useful (0 votes)
628 views4 pages

Database by Kuya NR

This document contains a 50 question multiple choice quiz on PL/SQL concepts like SELECT statements, stored procedures, exceptions, cursors, and more. The questions test knowledge of SQL and PL/SQL syntax as well as best practices for writing blocks of code, using variables, and handling exceptions. The document provides the question and a multiple choice answer for each item on the quiz.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
628 views4 pages

Database by Kuya NR

This document contains a 50 question multiple choice quiz on PL/SQL concepts like SELECT statements, stored procedures, exceptions, cursors, and more. The questions test knowledge of SQL and PL/SQL syntax as well as best practices for writing blocks of code, using variables, and handling exceptions. The document provides the question and a multiple choice answer for each item on the quiz.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

PROG-113A / ► Week 20: Second Quarter Exam / ► Second Quarter Exam (50/50) (PS: Pabago

bago ang questions, pero same lang sa ibang short quizes or learning activity yung questions and
sagot) <3 :)

Which of the following does NOT describes SELECT Statement in a PL/SQL.


Answer: Queries must return only one column.
You want to display all the records of employee the same with the salary employee number 103.
Answer: SELECT * FROM employees WHERE salary = (SELECT salary from employees where
employee_id= 103)
Which of the following stored procedure to create a procedure to that will be used to display the
employee id and salary of Steven King?
Answer: CREATE OR REPLACE PROCEDURE query_emp
(p_last_name IN employees.last_name%TYPE,
p_first_name IN employees.first_name%TYPE,
p_employee_id OUT employees.employee_id%TYPE,
p_salary OUT employees.salary%TYPE) IS
BEGIN
SELECT employee_id, salary INTO p_employee_id, p_salary
FROM employees
WHERE last_name = p_last_name AND first_name = p_first_name;
END query_emp;
Which of the folllowing is TRUE?
Answer: SQL code are embedded within PL/SQL statements
When an exception is user defined, the exception is raised ____________ .
Answer: Explicitly
Which of the folllowing is TRUE?
Answer: SQL code are embedded withing PL/SQL statements
Weak REF CURSOR is very flexible.
Answer: True
How do you test the output of a PL/SQL block?
Answer: Use a predefined Oracle package and its procedure
Restrictive, specifies a RETURN type, associates only with type-compatible queries are description
of a ________________.
Answer: Strong REF CURSOR
Which of the following DOES NOT describes an exception?
Answer: Exception is a PL/SQL error that is raised before program execution.
These are local variables declared in the parameter list of a subprogram specification.
Answer: Formal parameter
Which of the following rules is INCORRECT about cursor variables?
Answer: None of the choices.
When an exception is predefined by Oracle server, the exception is raised ____________ .
Answer: Explicitly
Which of the following DOES NOT describes an exception?
Answer: Exception is a PL/SQL error that is raised before program execution.
Evaluate the following PL/SQL.
CREATE OR REPLACE PROCEDURE query_employee
(p_id IN employees.employee_id%TYPE,
p_name OUT employees.last_name%TYPE,
p_salary OUT employees.salary%TYPE) IS
BEGIN SELECT last_name, salary INTO p_name, p_salary
FROM employeesWHERE employee_id = p_id;
END query_employee
Answer: No error
You want to know the total number of employees whose firstname starts with letter D.
Which of the folllowing PLS/SQL executes successfully?
Answer: DECLARE
v_first_name employees.first_name%TYPE := 'D%';
BEGIN
SELECT COUNT(*) INTO v_first_name FROM employees WHERE first_name LIKE v_first_name;
DBMS_OUTPUT.PUT_LINE(v_first_name);
END;
What is the error trapping function that returns the numeric value of the error code?
Answer: SQLCODE
You want to display the name, salary and tax of employee #150. Which of the PL/SQL will execute
successfully? Note tax is computed as 2% of the salary.
Answer: DECLARE
v_first_name VARCHAR2(50);
v_last_name VARCHAR2(50);
v_salary INTEGER(20);
v_tax INTEGER(10);
BEGIN
SELECT first_name, last_name, salary, salary * 0.02 INTO v_first_name, v_last_name, v_salary,
v_tax FROM employees WHERE employee_id = 150;
DBMS_OUTPUT.PUT_LINE('Firstname : '|| v_first_name);
DBMS_OUTPUT.PUT_LINE('Lastname : '|| v_last_name);
DBMS_OUTPUT.PUT_LINE('Salary : '|| v_salary);
DBMS_OUTPUT.PUT_LINE('Tax : '|| v_tax);
END;
Which of the following is the syntax to close a cursor?
Answer: CLOSE cursor_variable_name;
Which of the following rules is INCORRECT about cursor variables?
Answer: None of the choices.
What are the three PL/SQL block types?
Answer: Anonymous, Procedure, Function
You can trap any error by including a corresponding handler within the exception-handling section of
the PL/SQL block.
Answer: True
Which of the following describes weak REF CURSOR?
Answer: Associates with any query
Given the answer in item __________, which of the folllowing stored procedure will display the
employee id and salary of Steven King?
Answer: DECLARE
v_employee_id employees.employee_id%TYPE;
v_emp_sal employees.salary%TYPE;
BEGIN
query_emp('King', 'Steven', v_employee_id, v_emp_sal);
DBMS_OUTPUT.PUT_LINE('Employee ID ' || v_employee_id ||' earns '|| to_char(v_emp_sal,
'$999,999.00'));
END;
You have been tasked to update the database by creating a PL/SQL to increase the salary of all IT
Programmer employees by 50% of their existing salary.
Which of the following will execute successfully?
Answer: DECLARE
v_job_id employees.job_id%TYPE := 'IT_PROG';
BEGIN
UPDATE employees SET salary = salary *0.50 WHERE job_id = v_job_id;
END;
Which of the folllowing is required in a subquery?
Answer: SELECT
What is the exception name when PL/SQL has an internal problem
Answer: PROGRAM_ERROR
In the DECLARE section of the PL/SQL block,
Answer: All of the choices
Actions are being performed when error occurs during PL/SQL execution in the
Answer: EXCEPTION
What is the exception name when PL/SQL has an internal problem
Answer: PROGRAM_ERROR
Which of the folllowing statement describes PL/SQL?
Answer: PL/SQL is an Oracle proprietary, procedural, 3GL programming language
Evaluate the following PL/SQL.
DECLARE
v_employee_id employees.employee_id%TYPE := 114;
BEGIN
DELETE employees WHERE employee_id = v_employee_id;
END;
Answer: The PL/SQL will delete employee number 114.
Which of the following command is used to create a stand-alone procedure that is stored in the
Oracle database?
Answer: CREATE PROCEDURE
Evaluate the following PL/SQL.
DECLARE
v_email VARCHAR(20);
BEGIN
SELECT email INTO v_email FROM EMPLOYEES WHERE email like 'D%';
DBMS_OUTPUT.PUT_LINE ('Employees whose email address starts with letter D :'
|| v_email);
EXCEPTION
WHEN TOO_MANY_ROWS THEN
DBMS_OUTPUT.PUT_LINE (' Your select statement retrieved multiple rows.');
END;
Answer: The PL/SQL block will run successfully.
Which of the following is the syntax to define a REF CURSOR type?
Answer: TYPE ref_type_name IS REF CURSOR
[RETURN return_type];
The PL/SQL code block helps modularize code by using:
Answer: All of the choices
Which of the following is the syntax to fetch from a cursor variable?
Answer: FETCH cursor_variable_name INTO variable_name1
[,variable_name2,. . .] | record_name;
You want to display all records in the database whose salary is above the salary of Alexander
Hunold.
Answer: SELECT * from employees WHERE salary < (SELECT salary FROM employees WHERE
first_name = 'Alexander' AND last_name = 'Hunold')
Procedure can be stored in the database as a schema object.
Answer: True
In PL/SQL Block Structure, which of the following are mandatory?
Answer: BEGIN and END
PL/SQL stands for
Answer: Procedural Language extension to SQL
Which of the following is CORRECT about sub-queries?
Answer: Subquery execute before the main query executes.
Which of the following does NOT describes SELECT Statement in a PL/SQL.
Answer: Queries must return only one column.
PL/SQL Provides a block structure for executable units of ________________.
Answer: Code
Evaluate the SQL command
SELECT employee_id, salary from employees where salary = ANY (SELECT salary FROM
employees WHERE job_id = 'IT_PROG') AND job_id = 'ST_CLERK'
Answer: This has no error.
Which of the following PL/SQL will execute successfully?
Answer: DECLARE
v_salary INTEGER(20);
BEGIN
SELECT salary INTO v_salary FROM employees WHERE employee_id = 150;
END;
In PL/SQL Block Structure, which of the following are OPTIONAL?
Answer: None of the choices
Evaluate the following PL/SQL. At what line number is the error of the PL/SQL?
DECLARE
v_deptno NUMBER := 800;
e_invalid EXCEPTION;
BEGIN
DELETE FROM departments
WHERE department_id = v_deptno;
IF SQL % NOT_FOUND THEN
RAISE e_invalid;
END IF;
COMMIT;
EXCEPTION
WHEN e_invalid THEN
DBMS_OUTPUT.PUT_LINE('No such department id.');
END;
Answer: 7
What is the error trapping function that returns the numeric value of the error code?
Answer: SQLCODE
Fetch into a record when fetching from a cursor.
Answer: True

You might also like