Sunteți pe pagina 1din 6

LA9

Which of the following is CORRECT about sub-queries?

Subquery execute before the main query executes.

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'

This has no error.

Evaluate the SQL Command

SELECT job_id, job_title FROM jobs J WHERE INCLUDES


(SELECT * FROM employees WHERE J.job_id = e.job_id );
The SQL will return an error. Invalid "INCLUDES" parameter.
You want to display all the records of employee the same with the salary employee number 103.

SELECT * FROM employees WHERE salary = (SELECT salary from employees where employee_id= 103)

Which of the following is INCORRECT?


Use single-row operators with multiple-row subqueries

Which of the folllowing is required in a subquery?


SELECT

Sh9
Evaluate the SQL command
SELECT employee_id, job_id, salary from employees where salary < ALL (SELECT salary FROM employees
WHERE job_id = 'FI_ACCOUNT') AND job_id = 'IT_PROG'
The correct answer is: This has no error.

You want to display all records in the database whose salary is above the salary of Alexander Hunold.
The correct answer is: SELECT * from employees WHERE salary < (SELECT salary FROM employees WHERE
first_name = 'Alexander' AND last_name = 'Hunold')

You want to display the department name the same with the location of the Purchasing department.
The correct answer is: SELECT department_name from departments where location_id = (SELECT location_id from
departments where department_name = 'Purchasing')

Evaluate the SQL command


SELECT employee_id, last_name, first_name, job_id FROM employees WHERE department_id = (SELECT
max(department_id) FROM employees GROUP BY department_id)
The correct answer is: This will return an error. Single-row subquery returns more than one row.
You want to display all employee id, name, hired date and salary who are hired after employee 104 was hired.

The correct answer is: SELECT employee_id, last_name, hire_date, salary FROM employees WHERE
TO_NUMBER(TO_CHAR(hire_date, 'YYYY')) >
(SELECT TO_NUMBER(TO_CHAR(hire_date, 'YYYY')) FROM employees WHERE employee_id = 104)

La10
Actions are being performed when error occurs during PL/SQL execution in the
The correct answer is: EXCEPTION

PL/SQL Provides a block structure for executable units of ________________.


The correct answer is: Code
In PL/SQL Block Structure, which of the following are mandatory?
The correct answer is: BEGIN and END
Which of the following PL/SQL will execute successfully?

The correct answer is: DECLARE


v_salary INTEGER(20);
BEGIN
SELECT salary INTO v_salary FROM employees WHERE employee_id = 150;
END;
PL/SQL stands for

The correct answer is: Procedural Language extension to SQL

sh10
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.
The correct answer is: 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;
In the DECLARE section of the PL/SQL block

The correct answer is: All of the choices


What are the three PL/SQL block types?
The correct answer is: Anonymous, Procedure, Function
How do you test the output of a PL/SQL block?

The correct answer is: Use a predefined Oracle package and its procedure
Which of the folllowing statement describes PL/SQL?
the correct answer is: PL/SQL is an Oracle proprietary, procedural, 3GL programming language
Which of the folllowing is TRUE?

The correct answer is: SQL code are embedded withing PL/SQL statements
In PL/SQL Block Structure, which of the following are OPTIONAL?
The correct answer is: None of the choices

La11
Which of the following PL/SQL that will display the total number employees whose salary is 10000 and above?
The correct answer is: DECLARE
v_salary employees.salary%TYPE := 10000;
BEGIN
SELECT COUNT(*) INTO v_salary FROM employees WHERE salary >= v_salary;
DBMS_OUTPUT.PUT_LINE(v_salary);
END;
You have been tasked to update the database by creating a PL/SQL to increase the salary of all IT Programmer
employees by twice of their existing salary. Which of the following will execute successfully?
The correct answer is: DECLARE
v_job_id employees.job_id%TYPE := 'IT_PROG';
BEGIN
UPDATE employees SET salary = salary * 2 WHERE job_id = v_job_id;
END;

This is a type of cursor which is created and managed internally by the Oracle server to process SQL statements
The correct answer is: Implicit
Which of the following does NOT describes SELECT Statement in a PL/SQL.
The correct answer is: Queries must return only one column.
Evaluate the following PL/SQL.
1 DECLARE
2 v_employee_id employees.employee_id%TYPE := 114;
3 BEGIN
4 DELETE employees WHERE employee_id = v_employee_id;
5 END
The correct answer is: The PL/SQL will delete employee number 114.

sh11
Evaluate the folllowing PL/SQL
1. DECLARE
2. v_job_id employees.job_id%TYPE := 'IT_PROG';
3. v_last_name employees.last_name%TYPE := 'Lim';
4. v_first_name employees.first_name%TYPE := 'Steven';
5. BEGIN
6. INSERT INTO employees (employee_id, last_name, first_name, email, hire_date, job_id, salary)
7. VALUES (employees_seq.NEXTVAL, v_last_name, v_first_name, v_last_name||v_first_name||'@gmail.com',
CURRENT_DATE, v_job_id, 63000);
8. END;
The correct answer is: No Error.
Evaluate the PL/SQL
1. DECLARE
2. v_first_name VARCHAR2(50);
3. v_last_name VARCHAR2(50);
4. v_salary INTEGER(20);
5. BEGIN
6. SELECT first_name, last_name, salary INTO v_first_name, v_last_name, v_salary FROM employees WHERE
department_id = 60;
7. DBMS_OUTPUT.PUT_LINE('Firstname : '|| v_first_name);
8. DBMS_OUTPUT.PUT_LINE('Lastname : '|| v_last_name);
9. DBMS_OUTPUT.PUT_LINE('Salary : '|| v_salary);
10. END;
The correct answer is: Error in Line 6.
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?
The correct answer is: 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;
You want to know the total number of employees whose firstname starts with letter D.
Which of the folllowing PLS/SQL executes successfully?
The correct answer is: 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;

Evaluate the following PL/SQL.


1 DECLARE
2 v_employee_id employees.employee_id%TYPE := 114;
3 BEGIN
4 DELETE employees WHERE employee_id = v_employee_id;
5 END;
The correct answer is: The PL/SQL will delete employee number 114.

LA12
When an exception is predefined by Oracle server, the exception is raised ____________ .

The correct answer is: Explicitly


When an exception is user defined, the exception is raised ____________ .
The correct answer is: Explicitly
You can use this procedure to issue user-defined error messages from stored subprograms.

The correct answer is: RAISE_APPLICATION_ERROR


you can trap any error by including a corresponding handler within the exception-handling section of the PL/SQL
block.

The correct answer is 'True'.


Which of the following syntax to declare EXCEPTION named e_invalid_id?
The correct answer is: e_invalid_id EXCEPTION;
Sh12

S-ar putea să vă placă și