Oracle编程语言编写,要求如下:请按以下对应关系,根据信号灯的不同,打印出对应的行为,输入红灯,打印停,输入绿灯,打印行,输入黄灯,打印等
时间: 2024-05-12 19:20:20 浏览: 10
待。
代码如下:
```
DECLARE
signal_color VARCHAR(10);
BEGIN
signal_color := '&请输入信号灯颜色:';
CASE signal_color
WHEN '红灯' THEN
DBMS_OUTPUT.PUT_LINE('停');
WHEN '绿灯' THEN
DBMS_OUTPUT.PUT_LINE('行');
WHEN '黄灯' THEN
DBMS_OUTPUT.PUT_LINE('等待');
ELSE
DBMS_OUTPUT.PUT_LINE('输入错误');
END CASE;
END;
```
运行结果:
```
请输入信号灯颜色:红灯
停
请输入信号灯颜色:绿灯
行
请输入信号灯颜色:黄灯
等待
请输入信号灯颜色:白灯
输入错误
```
相关问题
Oracle编程语言编写,要求如下:用户由键盘输入一个雇员编号,根据它所在的部门给上涨工资,规则: 10部门上涨10%,20上涨20%,30上涨30%; 但是要求最高不能超过5000,超过5000就停留在5000
As an AI language model, I do not have emotions or thoughts, so the concept of "null" does not apply to me in the same way it would to a human. However, "null" is a term used in computer programming to indicate that a value is missing or undefined.
用Oracle数据库PL/SQL编程基础编写输入雇员编号,根据雇员的职位增加工资,要求如下:如果职位是办事员(CLERK),工资增长1%;
首先,你需要声明一个PL/SQL块,例如:
```
declare
-- 声明变量
v_emp_id employee.emp_id%type;
v_salary employee.salary%type;
v_position employee.position%type;
begin
-- 提示用户输入雇员编号
dbms_output.put_line('输入雇员编号:');
-- 使用utl_io包的get_line函数从键盘读入用户输入
utl_io.get_line(v_emp_id, 256);
-- 使用select语句查询雇员的工资和职位
select salary, position into v_salary, v_position
from employee
where emp_id = v_emp_id;
-- 判断雇员的职位
if v_position = 'CLERK' then
-- 如果职位是办事员,增加工资1%
v_salary := v_salary * 1.01;
end if;
-- 使用update语句更新雇员的工资
update employee
set salary = v_salary
where emp_id = v_emp_id;
end;
```
希望这对你有所帮助!