日期:2014-05-17 浏览次数:20861 次
create or replace function FunAlterDepartmentName(v_depno varchar(20)) return varchar2 is Result varchar2; begin update scott.EMP set deptname = 'IT' where deptno = v_depno; Result = 'IT'; return(Result); end FunAlterDepartmentName;
------解决方案--------------------
CREATE OR REPLACE PROCEDURE USP_DML(V_DEPNO IN VARCHAR2,V_DEPNAME IN VARCHAR2,v_EMP_ID IN VARCHAR2) AS DECLARE V_SALARY NUMBER; V_AVG_SALARY NUMBER; BEGIN UPDATE SCOTT.EMP SET DEPNAME='IT' WHERE DEPNO=V_DEPNO; DELETE FROM SCOTT.EMP WHERE DEPNAME=V_DEPNAME; SELECT AVG(SALARY) INTO V_AVG_SALARY FROM SCOTT.EMP; SELECT SALARY INTO V_SALARY FROM SCOTT.EMP WHERE EMP_ID=V_EMP_ID; IF(V_SALARY < V_AVG_SALARY) THEN update SCOTT.EMP set salary=salary+500 where emp_id=v_EMP_ID; END IF; END;