創(chuàng)建過程的語法:

Code
create [or replace] procedure procedure_name
[(argument[{in|out|in out}] type,

argument[{in|out|in out}] type)] {is|as}
procedure_body
簡單的例子:

Code
create procedure RaiseError(
/*if p_Raise is true,then an unhandled error is raised.
if p_Raise is false,the procedure completes successfully.*/
p_Raise in boolean:=true,
p_ParameterA out number) as
begin
p_Parameter1:='abcdwxc';
p_Parameter2:=143;
end ParameterLength;
刪除過程語法:
drop procedure procedure_name;
2、創(chuàng)建函數(shù)的語法:

Code
create [or replace] function function_name
[(argument[{in|out|in out}] type,

argument[{in|out|in out}] type)]
return return_type {is|as}
function_body
簡單函數(shù)的例子:
create function ClassInfo(
p_Department classes.department%type,
p_Course classes.course%type)
return varchar is
v_CurrentStudents number;
v_MaxStudents number;
v_PercentFull number;
begin
select current_students,max_students
into v_CurrentStudents,v_MaxStudents
from classes
where department=P_Department and course=P_Course;
--計算百分比
v_PercentFull:=v_CurrentStudents/V_MaxStudent*100;
if v_PercentFull=100 then
return 'Full';
elseif v_PercentFull>80 then
return 'Some Room';
elseif v_PercentFull>60 then
return 'More Room';
elseif v_PercentFull>0 then
return 'Lots of Room';
else
return 'Empty';
end if
end ClassInfo;
刪除函數(shù)語法:
drop function function_name;
posted on 2009-01-31 12:18
David1228 閱讀(493)
評論(0) 編輯 收藏 所屬分類:
數(shù)據(jù)庫