函数,存储过程

yo_258 2009-04-22 09:46:19
表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;
...全文
85 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
tanzuwen 2009-04-22
  • 打赏
  • 举报
回复
select Id,name,
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
superhsj 2009-04-22
  • 打赏
  • 举报
回复
我正在给lz解释,lz还是在很认真的学习的,呵呵
[Quote=引用 4 楼 woodheart 的回复:]
高,直接到这边来找干活的人了
[/Quote]
superhsj 2009-04-22
  • 打赏
  • 举报
回复
函数和过程关键字都漏了,lz自己加吧
woodheart 2009-04-22
  • 打赏
  • 举报
回复
高,直接到这边来找干活的人了
superhsj 2009-04-22
  • 打赏
  • 举报
回复
create or replace test return number as
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;
superhsj 2009-04-22
  • 打赏
  • 举报
回复
漏了一个
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;
superhsj 2009-04-22
  • 打赏
  • 举报
回复
select rownum,name,
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;

17,140

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧