PL/SQL。。 用一个过程将表emp1中的数据插入到emp2中。

表emp1(empno ,ename,job,mgr,hiredate,sal,comm,deptno,fag)表emp2(empno,ename,job,sal,comm,deptno,flag,loc,hiredate)表emp2中无数据。表dept1(deptno,dname,loc,flag)。用一个过程将表emp1及dept1中的数据插入到emp2中,并且当奖金comm<=1000时 奖金增加100,1000<comm<2000时,增加200,comm>=2000时增加300。求高手帮忙。。。

insert into emp2 (empno,ename,job,sal,comm,deptno,flag,loc,hiredate)
select a.empno,a.ename,a.job,a.sal,
case when a.comm between 0 and 1000 then comm+100 end
case when comm>1000 and comm<2000 then comm+200 end
case when comm>=2000 then comm+300 end,
a.deptno,b.flag,b.loc,a.hiredate from emp1
where a,dept1 b where a.deptno=b.deptno;

貌似也用不着存储过程,前边直接加个begin,后边加个end就是存储过程了
温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-08-26
··@··