PL/SQL 创建一个存储过程,以部门号为参数返回该部门的人数和平均工资(保留两位小数)。

CREATE OR REPLACE PROCEDURE proc_return_deptinfo(
	p_deptno %TYPE,
	p_avgsal %TYPE,
	p_count   NUMBER)
AS
BEGIN
	SELECT avg(salary),count(*) INTO p_avgsal,p_count FROM employees
	WHERE department_id=p_deptno;
EXCEPTION
	WHEN NO_DATA_FOUND THEN
    	DBMS_OUTPUT.PUT_LINE('The department don''t exists! ');
END proc_return_deptinfo;
..................................................................................................
DECLARE
	v_avgsal %TYPE;
	v_count  NUMBER;
BEGIN
	proc_return_deptinfo(&departmentID,v_avgsal,v_count);
	DBMS_OUTPUT.PUT_LINE('人数:'||v_count||'    '|| '平均工资:'||v_avgsal);
END; 

你可能感兴趣的:(test)