Auto commit
This commit is contained in:
parent
85aedd7dcf
commit
eb6a1ba10c
@ -115,6 +115,21 @@ INSERT INTO employee (emp_name, salary, hire_date, dept_id, job_id) VALUES
|
||||
|
||||
创建一个存储函数 `calculate_annual_salary`,接受员工的月薪作为参数,返回其年薪(假设年薪为月薪的 12 倍)。
|
||||
|
||||
```sql
|
||||
DELIMITER $$
|
||||
DROP FUNCTION IF EXISTS calculate_annual_salary;
|
||||
CREATE FUNCTION calculate_annual_salary(sal DECIMAL(10, 2))
|
||||
RETURNS DECIMAL(10, 2)
|
||||
DETERMINISTIC
|
||||
BEGIN
|
||||
RETURN sal*12;
|
||||
END $$
|
||||
DELIMITER ;
|
||||
SELECT calculate_annual_salary(3000);
|
||||
```
|
||||
|
||||
|
||||
|
||||
#### 练习题 2: 计算员工工龄
|
||||
|
||||
创建一个存储函数 `calculate_years_of_service`,接受员工的入职日期作为参数,返回该员工的工龄(以年为单位)。
|
||||
|
Loading…
x
Reference in New Issue
Block a user