Overview
This function updates an existing employee record in thetab_emplea table. It allows modification of all employee fields except the employee ID, which is used to identify the record to update.
Function Signature
Parameters
Employee ID to update (identifies the record)
Employee’s first name
Employee’s last name
Gender indicator (e.g., ‘M’ for male, ‘F’ for female)
Employee’s address
Employee’s phone number
Socioeconomic stratum indicator (1-6)
Civil status indicator (e.g., ‘S’ for single, ‘C’ for married)
Number of children
Blood type (e.g., ‘O+’, ‘A-’, ‘B+’, ‘AB-’)
Employee’s age
Position ID (foreign key to tab_cargos)
Base salary amount
Date of hire
Return Type
VOID - This function does not return a value. It performs an UPDATE operation.
Business Logic
- Record Identification: Uses
wid_empleato locate the specific employee record to update - Complete Update: All fields are updated simultaneously; the function does not support partial updates
- Referential Integrity: The new
wid_cargomust exist in thetab_cargostable - Silent Failure: If the employee ID does not exist, the function completes without error but no records are updated
Usage Example
Common Use Cases
- Data Correction: Fix incorrectly entered names or personal information
- Promotion: Update position and salary when an employee is promoted
- Personal Changes: Update marital status, number of children, address, or phone number
- Annual Updates: Update age and salary during annual reviews
Notes
- All employee fields must be provided, even if only one field needs to be updated
- To perform a partial update, first query the current values and pass them along with the changed fields
- The function does not validate if the employee ID exists before attempting the update
- Ensure the position ID exists in
tab_cargosbefore calling this function
Source
Location:~/workspace/source/func/emplea/fun_update_emplea.sql:9
Author: Camilo SuárezDate: 24/03/2025