emp表
empno   ename     job           sal       deptno
7369 SMITH CLERK     1500       20
7499 ALLEN SALESMAN     1800       30
7521 WARD SALESMAN     2000       30
7566 JONES MANAGER     2300       20
7654 MARTIN SALESMAN     1900       30
7698 BLAKE MANAGER     1789       30
7782 CLARK MANAGER     3200       10
7788 SCOTT ANALYST     2300       20
7839 KING PRESIDENT    890        10
7876 ADAMS CLERK     1300       30
7900 JAMES CLERK     2300       20
7902 FORD ANALYST     2200       10
7934 MILLER CLERK     3100       10
功能:对10部门的工资加100,20部门的工资加200,30部门的加300
本人知道容易,但平时写得少,呵呵,谢谢.

解决方案 »

  1.   

    一条SQL啊
    update emp set sal = (case deptno when 10 then sal+100 when 20 then sal+200 when 30 then sal+300 else sal end);
      

  2.   

    CREATE OR REPLACE PROCEDURE uptable IS
    BEGIN
    update emp set sal = (case deptno when 10 then sal+100 when 20 then sal+200 when 30 then sal+300 else sal end);
    end;
    ..........
     
      

  3.   

    create or replace procedure updateempBeginupdate emp set sal = (case deptno when 10 then sal+100 when 20 then sal+200 when 30 then sal+300 else sal end);
       
    End;Exception    When others then       Rollback;End;
      

  4.   

    create or replace procedure upemp
    as
    deptno number;
    sal    number;
    Beginupdate emp set sal = (case deptno when 10 then sal+100 when 20 then sal+200 when 30 then sal+300 else sal end);
       
    End upemp;
      

  5.   

    CREATE OR REPLACE PROCEDURE UPEMP AS
      DEPTNO NUMBER;
      SAL    NUMBER;
    BEGIN
      UPDATE EMP
         SET SAL = DECODE(DEPTNO, 10, SAL + 100, 20, SAL + 200, 30, SAL + 300);
    END UPEMP;
      

  6.   

    CREATE OR REPLACE PROCEDURE uptable IS 
    BEGIN 
    update emp set sal = (case deptno when 10 then sal+100 when 20 then sal+200 when 30 then sal+300 else sal end); 
    end; 
      

  7.   

    create or replace procedure test_p1 is
      cursor emp_cursor(no number) is
        select ename from emp where deptno=no;
       v_ename emp.ename%type;
    BEGIN
       open emp_cursor(10);
       loop
         fetch emp_cursor into v_ename;
         exit when emp_cursor%notfound;
         dbms_output.put_line('雇员名:'||v_ename);
       end loop;
       close emp_cursor;
       end;