日期:2014-05-16  浏览次数:20577 次

oracle function的基本语句

CREATE OR REPLACE FUNCTION "OMSFM"."TEST1"(inParam in varchar2,outParam out number)

RETURN VARCHAR2
IS
?avgSal number;
BEGIN
? select? avg(salary) into avgSal from test where name like inParam||'%';
? outParam:=avgSal;
? --if else? 语句
? IF avgSal=20 THEN
???? DBMS_OUTPUT.PUT_LINE('2Sample output outParam='|| avgSal);
? ELSIF avgSal=30 THEN
??? DBMS_OUTPUT.PUT_LINE('3Sample output outParam='|| avgSal);
? ELSIF avgSal=10 THEN
??? DBMS_OUTPUT.PUT_LINE('11Sample output outParam='|| avgSal);
? END IF;
--do loop
? RETURN (avgSal);
END;