Knowee
Questions
Features
Study Tools

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

Question

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

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

Solution

Here is a step-by-step guide to creating a PL/pgSQL procedure to increment the salaries of employees based on the conditions you provided:

Step 1: Define the procedure.

CREATE OR REPLACE PROCEDURE update_salary(emp_id INT)
LANGUAGE plpgsql
AS $$

Step 2: Declare the variables you will use.

DECLARE 
    emp_name VARCHAR;
    emp_salary INT;

Step 3: Begin the procedure body.

BEGIN

Step 4: Retrieve the name and salary of the employee with the given ID.

    SELECT name, salary INTO emp_name, emp_salary
    FROM Employees
    WHERE id = emp_id;

Step 5: Check if the employee's salary is less than 35000. If it is, increase it by 15%. Otherwise, increase it by 10%.

    IF emp_salary < 35000 THEN

This problem has been solved

Similar Questions

In PostgreSQL, create a PL/pgSQL block that defines a procedure namedupdate_employee_salary which takes two parameters: employee_id and new_salary. This procedure should update the salary ofthe employee with the given employee_id to the new salary value. Assume “employee” table with fields – eid, ename and salary

A) Write PL/pgSQL function to increment the employee’s salary by 10% if his/her department is ‘HR’ for given(inputted)employee_id.Schema: Employee(employee_id, first_name, last_name, department, salary)B) Write PL/pgSQL function to find the number of Sundays between given dates

In PostgreSQL, create a PL/pgSQL block that defines a function named calculate_salary_bonus which takes two parameters:employee_id and bonus_percentage. This function should calculate the bonus amount for the employee with the givenemployee_id based on their current salary and the provided bonus percentage. Assume “employee” table with fields – eid, enameand salary

Which of the below queries displays employees' name and new salary after the increment of 1000

Problem statementSend feedbackSuppose you have a list of employees in a company, and each employee is represented as an object with the following properties:"id" - a unique identifier for the employee"name" - the employee's name"department" - the department the employee works in"salary" - the employee's current salaryObjectives:You want to make a modification to the list of employees to reflect a recent company-wide salary increase. You have been provided with the following information:Salaries for employees in the "sales" department should be increased by 10%.Salaries for employees in the "engineering" department should be increased by 15%.Salaries for employees in all other departments should be increased by 5%.You need to write a function "increaseSalaries" that takes an array of employee objects and returns a new array of employee objects where each employee's salary has been updated based on their department. The original array of employees should be left unchanged.

1/3

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.