MySQL Stored Procedure Batch Salary Increment Example

MySQL Stored Procedure Example - Batch Salary Increment

Open your MySQL Query Editor then copy & paste the below code to make a Stored Procedure which will take Increment percentage as parameter and Increment Salary of all employees in MySQL:

   delimiter |
   CREATE PROCEDURE SP_SALARY_INCREMENT(P_Percentage DOUBLE)
      BEGIN
            UPDATE      employees
            SET         Salary=Salary+(Salary*P_Percentage/100);
      END;
   |

MySQL Stored Procedure Example - Batch Salary Increment - MySQL Query Editor Output

Again open your MySQL Query Editor then copy & paste the below code to execute the Stored Procedure & get the desired result:

   call SP_SALARY_INCREMENT(10.5);

MySQL Stored Procedure Example - Executing Stored Procedure - MySQL Query Editor Output

 

Related Tutorial Examples

  1. MySQL Stored Procedure: Variable Example
  2. MySQL Stored Procedure: CREATE TABLE SELECT... Example
  3. MySQL Stored Procedure Function: How to Drop a Function Example
  4. MySQL Stored Procedure Function: How to Drop a Stored Procedure Example
  5. MySQL Stored Procedure Function: Making hello world Function using aliase Example
  6. MySQL NULLIF() Nested Function Example
  7. MySQL NULLIF() Function Datetime Value Example
  8. MySQL NULLIF() Function String Value Example
  9. Parentheses in SQL Command MySQL Example
  10. 20 steps to make CakePHP Blog Project

No comments:

Post a Comment

leave your comments here..