Overview
This function inserts a new employee into thetab_emplea table. The employee ID is automatically generated by incrementing the maximum existing ID by 1.
Function Signature
Parameters
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 INSERT operation.
Business Logic
- Automatic ID Generation: The employee ID is automatically calculated as
MAX(id_emplea) + 1, starting from 1 if no employees exist - Referential Integrity: The function expects a valid
wid_cargothat exists in thetab_cargostable - Complete Record: All employee information must be provided; no fields are optional
Usage Example
Notes
- This function was created due to referential integrity constraints and must be executed before inserting records into
tab_novedadesandtab_nomina - The employee ID is auto-generated and should not be provided by the caller
- Ensure the position ID exists in
tab_cargosbefore calling this function
Source
Location:~/workspace/source/func/emplea/fun_insert_emplea.sql:10
Author: Camilo SuarezDate: 24/03/2024