????Sql????
????-- ???????????????????????????  
????create or replace trigger tr_emp_salary  
????-- update of ???????????Щ?б??????????????????????????of ???????????  
????before update of sal on emp  
????-- ????????????м???????  
????for each row  
????-- ????????????????????Declare?ж???  
????declare 
????maxSalary number(10??2);  
????begin 
????select max(sal) into maxSalary from emp;  
????if :new.sal > maxSalary then 
????raise_application_error(-20010??'???????????????????');  
????end if;  
????end;  
????/ 
????Sql????
????-- ???????????????????????????????????????20%  
????create or replace trigger tr_emp_say
????before update of sal on emp
????for each row  
????-- ??????д???????????  
????when (new.sal < old.sal or new.sal > old.sal*1.2)  
????begin 
????raise_application_error(-20011??'????????????н???????????????????20%??');   
????end;  
????/
????????????????????????е??Щ??????
????Sql????
????-- ?????????  
????select trigger_name??status from user_triggers;  
????-- ?????????  
????alter trigger tr_emp_salary disable;  
????-- ????????  
????alter trigger tr_emp_salary enable;  
????-- ?????????д?????  
????alter table emp disable all triggers;  
????-- ?????????д?????  
????alter table emp enable all triggers;  
????-- ???±???????  
????--alter trigger tr_emp_salary compile;  
????-- ?????????  
????drop trigger tr_emp_salary; 
????????????洢PL/SQL???
?????洢PL/SQL?????洢?????????????????????????????????洢??????????????PL/SQL????????????У???????????????????????????????????????????????????κ?????????з??????
??????????????????????
????in???????????????????????????????????????????????????????
????out?????????????????????????????????????????????????????????
????in out?????????????
?????????????洢????
????????????????????????б?????????д???洢????????С????????????????????з??????
?????洢???????????
????create [or replace] procedure ?????? [(?????? ?????? ?????????...)] is|as
????[declaration]  --???巋??
????begin 
????--??в???
????[exception] 
????--?????????
????end [??????];
?????????????У??????????С?
????1.??SQL>??????μ??ù????execute ???????????? ...??
????2.??PL/SQL???е??ù???????????????? …)??????????PL/SQL???
???????????????顢??????洢??????????е??á?
?????洢?????п?????????DML???select??insert??update??delete??????????????DDL???
?????洢?????????????DDL??????DDL????????????????????У???????execute immediate???????????????????????????????SQL????????????л??????????PL/SQL????
?????洢?????д????????????????????????
????create or replace procedure pk_auto_increment_pro(t_name varchar2) is
????v_ddl varchar2(2000);
????begin
????v_ddl := 'create or replace trigger pk_auto_increment_' || t_name ||
????' before insert on ' || t_name ||
????' for each row
????begin
????dbms_output.put_line(''????id:'' ||:new.id);
????select test_seq.nextval into :new.id from dual;
????dbms_output.put_line(''?????id:'' ||:new.id);
????end;';
????execute immediate v_ddl;
????end;
???????????????
??????????????????????????????????????з??????
??????????????
????create [or replace] function ?????? [(?????б?)] return ????????? is|as
????[local declarations] --???巋??
????begin
????--??в???
????return ???;       ??????retutn??????????
????exception
????--?????????
????end;
?????????????ú?????
????1.??SQL>??????μ??ú???
????var varName ????;           --???????
????call ?????? into :varName;  
????print varName;
????2.??SQL???PL/SQL???е??ú??????????????????PL/SQL???????????÷?
????????????????????????????????????????
?????????塢??
??????????????????????????????????????????????????Э????????????????????Щ??????洢???????????????£?????????洢????????????????????????????????????????????棬?′??????????????????黯??
????????????????
????1.?????????java????
????????淶??????????????洢????????????
???????????????
????create [or replace] package ???? is|as
????--????????
????function ?????? [(?????б?)] return ????????;
????--?洢???????
????procedure ?洢?????? [(?????б?)];
????end [????];
????2.???壨????java?????
??????????????淶
????????????????
????create [or replace] package body ???? is|as
????--???????
????function ?????? [(?????б?)] return ???????? is|as
???????????????
????--?洢???????
????procedure ?洢?????? [(?????б?)] is|as
?????洢???????????
????end [????];
??????e??????????????.?????????
????????洢??????????????????Σ?????ù????????????()???????????
???????ú?????????????????Σ???SQL*Plus?????У??????()???????????