Knowee
Questions
Features
Study Tools

Consider the following PL/SQL block:DECLARE    v_emp_count NUMBER;BEGIN    SELECT COUNT(*) INTO v_emp_count FROM employees WHERE department_id = 10;    IF v_emp_count > 0 THEN        UPDATE employees SET salary = salary * 1.1 WHERE department_id = 10;    END IF;    SAVEPOINT update_done;    DELETE FROM employees WHERE department_id = 20;    IF SQL%ROWCOUNT = 0 THEN        RAISE_APPLICATION_ERROR(-20001, 'No employees to delete in department 20');    END IF;EXCEPTION    WHEN OTHERS THEN        ROLLBACK TO update_done;        RAISE;END;What will happen if there are no employees in department 20?The salaries of employees in department 10 will be updated, and an exception will be raised with the message 'No employees to delete in department 20'.The transaction will be completely rolled back, and no changes will be committed to the database.The updates to employees in department 10 will be rolled back, and an exception will be raised with the message 'No employees to delete in department 20'.Only the DELETE operation will be rolled back, and the update to employee salaries in department 10 will be committed to the database.

Question

Consider the following PL/SQL block:DECLARE    v_emp_count NUMBER;BEGIN    SELECT COUNT(*) INTO v_emp_count FROM employees WHERE department_id = 10;    IF v_emp_count > 0 THEN        UPDATE employees SET salary = salary * 1.1 WHERE department_id = 10;    END IF;    SAVEPOINT update_done;    DELETE FROM employees WHERE department_id = 20;    IF SQL%ROWCOUNT = 0 THEN        RAISE_APPLICATION_ERROR(-20001, 'No employees to delete in department 20');    END IF;EXCEPTION    WHEN OTHERS THEN        ROLLBACK TO update_done;        RAISE;END;What will happen if there are no employees in department 20?The salaries of employees in department 10 will be updated, and an exception will be raised with the message 'No employees to delete in department 20'.The transaction will be completely rolled back, and no changes will be committed to the database.The updates to employees in department 10 will be rolled back, and an exception will be raised with the message 'No employees to delete in department 20'.Only the DELETE operation will be rolled back, and the update to employee salaries in department 10 will be committed to the database.

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

The updates to employees in department 10 will be rolled back, and an exception will be raised with the message 'No employees to delete in department 20'.

Similar Questions

Examine the structure of employee table. You issue the following query:DECLAREl_vc_firstname employee.emp_name%type;l_salary employee.salary%type;BEGINSELECT emp_name, salary INTO l_vc_firstname, l_salary FROM employee WHERE emp_id=201;dbms_output.put_line('Number of rows processed: '||sql%rowcount);END;/What will be the outcome of above query?

reate PL/pgSQL procedure for the increment of employees where in salary less than 35000 will get hike of 15% in their previoussalary and other will get 10% hike in their previous salary. Using following schema, Employees (id, name, department, salary)call the procedure by id and print employee’s name with their updated salary

Problem StatementIn a company's Employee Management System, a database table named "Employees" that stores information about employees, including their EmployeeID, EmployeeName, Department, and Salary.The HR department needs a mechanism to delete employee records from the system when an employee leaves the company or for any other valid reason. To address this requirement, you are tasked with creating a stored procedure named "DeleteEmployee," which takes an EmployeeID as input and deletes the corresponding employee record from the "Employees" table.The following table is already created, and the records are inserted into the table.TABLE: Employees EmployeeID INT PRIMARY KEY, EmployeeName VARCHAR(50), Department VARCHAR(50), Salary DECIMAL(10, 2)Prepopulated Records:Input format :The input records are already prepopulated, as given in the problem statement.Output format :The stored procedure deletes the employee record based on the provided EmployeeID.The output should display the employee details after deletion as shown below.EmployeeID EmployeeName Department Salary1 John Doe IT 60000.002 Jane Smith HR 55000.003 Bob Johnson Marketing 70000.004 Alice Williams Finance 80000.00EmployeeID EmployeeName Department Salary1 John Doe IT 60000.003 Bob Johnson Marketing 70000.004 Alice Williams Finance 80000.00Refer to the sample output for the column headers.

Neha, the manager of an employee database, has identified a need to streamline workforce information in the company's database. She noticed that employees with salaries below a specific threshold are considered inactive.To address this, Neha is looking to create a function called DeleteInactiveEmployees that will facilitate the removal of records for employees with salaries below the defined threshold. Your task is to help Neha by implementing the DeleteInactiveEmployees function, taking the salary threshold as a parameter, and deleting records for inactive employees.The following table is already created, and the records are inserted into the table.Table:Employee EmployeeID INT PRIMARY KEY, FirstName VARCHAR(50), LastName VARCHAR(50), Salary DECIMAL(10, 2)Prepopulated Records:Input format :The input records are already prepopulated, as given in the problem statement.Output format :The output should return an integer representing the number of records deleted from the Employee table.RecordsDeleted4Refer to the sample output for the column headers.Note :The program will be evaluated only after the “Submit Code” is clicked.Extra spaces and new line characters in the program output will result in the failure of the test case.

Which SQL statement produces an error? Select one:a.SELECT department_id, job_id, AVG(salary)FROM emp_dept_vuGROUP BY department_id, job_id;b.SELECT job_id, SUM(salary)FROM emp_dept_vuWHERE department_id IN (10,20)GROUP BY job_idHAVING SUM(salary) > 20000;c.None of the statements produce an error; all are valid. d.SELECT department_id, SUM(salary)FROM emp_dept_vuGROUP BY department_id;e.SELECT *FROM emp_dept_vu;

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.