表a : 表b:
Id name int_rate id name int_rate1 int_rate2 int_rate3
1 rose 37 1 rose 37 34 38
2 rose 34 2 john 35 45 55
3 rose 38
1 john 35
2 john 45
3 john 55
利用pl/sql程序块把表a变成表b?表
Id salary name
1 4500 rose创建存储过程,输入员工薪水范围,返回员工工号、姓名、薪水结果集。结果集按薪水升序排列
创建函数更新员工薪水,低于2000,且姓王的员工加5%,其他不变,更新成功返回0,否则返回1;
Id name int_rate id name int_rate1 int_rate2 int_rate3
1 rose 37 1 rose 37 34 38
2 rose 34 2 john 35 45 55
3 rose 38
1 john 35
2 john 45
3 john 55
利用pl/sql程序块把表a变成表b?表
Id salary name
1 4500 rose创建存储过程,输入员工薪水范围,返回员工工号、姓名、薪水结果集。结果集按薪水升序排列
创建函数更新员工薪水,低于2000,且姓王的员工加5%,其他不变,更新成功返回0,否则返回1;
sum(case id when 1 then int_rate else 0 end) int_rate1,
sum(case id when 2 then int_rate else 0 end) int_rate2,
sum(case id when 3 then int_rate else 0 end) int_rate3
from a group by name;create or replace test return number as
begin
update table set 薪水=薪水*(1+0.05) where 姓='王' and 薪水<2000;
return 0;
exception
when others then
return 1;
end;
create or replace test1(val1 in number,val2 in number)
v_id number;
v_name varchar2(10);
v_salary number;
as
cursor v_cur is select id,name,salary from table where salary<=val2 and salary>=val1 order by salary;
begin
open v_cur;
fetch v_cur into v_id,v_name,v_salary;
while v_cur %found loop
dbms_output.put_line(v_id||chr(9)||v_name||chr(9)||v_salary);
fetch v_cur into v_id,v_name,v_salary;
end loop;
close v_cur;
end;
begin
update table set salary=salary*(1+0.05) where name like '王%' and salary<2000;
commit;
return 0;
exception
when others then
return 1;
end;
sum(case Id when 1 then int_rate else 0 end)int_rate1,
sum(case Id when 1 then int_rate else 0 end)int_rate2,
sum(case Id when 1 then int_rate else 0 end)int_rate3,
from a group by name