Oracle´æ´¢¹ý³Ì£¬º¯Êý¡£
--ÔÚÓ¦ÓóÌÐòÖÐÍùÍùÓÐЩ¹Ì¶¨µÄÊý¾Ý¿â²Ù×÷£¬ÎÒÃdz£³£ÎªÖÂл¹Ì¶¨µÄ²Ù×÷¶¨ÒåÁËһЩ´æ´¢¹ý³Ì¡£ÕâЩ´æ´¢¹ý³Ì²»½ö
--¿ÉÒÔ¼ò»¯¿Í»§¶ËµÄÓ¦ÓóÌÐòµÄ¿ª·¢ºÍά»¤¡£¶øÇÒ»¹¿ÉÒÔÌá¸ßÓ¦ÓõÄÔËÐÐÐÔÄÜ¡£
-- ´´½¨´æ´¢¹ý³ÌµÄÓï·¨¡£
create [or replace] procedure <¹ý³ÌÃû>[(²ÎÊý)]
is|as
[¾Ö²¿±äÁ¿ÉùÃ÷]
begin
¿ÉÖ´ÐÐÓï¾ä
exception
Òì³£´¦Àí
end
--ÔÚ¶¨ÒåÖÐ IS|AS ¿ÉÒÔ¸ù¾ÝÏ°¹ßÑ¡ÔñIS »òÕßAS ³ýÁ˶¨Ò岿·Ö¡£ÆäÓàµÄÓ﷨ͬPL/SQLµÄÓï·¨¡£
Àý£º ¡£
-- 1 ¢ÙÒ»¸öÎ޲εĴ洢¹ý³Ì¡£
create or replace procedure proc_1--proc_1´æ´¢¹ý³ÌÃû³Æ
is
i number(3);--¶¨Òå±äÁ¿
begin
i:=100;
dbms_output.put_line(i);
end;
--¢Úµ÷Óô洢¹ý³Ì¡£
begin
proc_1;
end;
--Ò»¸öÎÞ²ÎÊýµÄ´æ´¢¹ý³Ì´´½¨Íê±Ï
2 Ò»¸öÓвÎÊýµÄ´æ´¢¹ý³Ì
´æ´¢¹ý³Ì¶¨ÒåµÄʱºò¿ÉÒÔʹÓòÎÊýÒ²¿ÉÒÔ²»ÊµÓòÎÊý¡£
²ÎÊýÀàÐÍ
· ÔÚPL/SQL¹ý³ÌÖУ¬¿ÉÒÔÓÐ3ÖÖÀàÐ͵IJÎÊý¡£
· IN²ÎÊý£º¶ÁÈë²ÎÊý£¬Ö÷³ÌÐòÏò¹ý³ÌÖд«µÝ²ÎÊý¡£
· OUT²ÎÊý£ºÊä³ö²ÎÊý£¬¹ý³ÌÏòÖ÷³ÌÐò´«µÝ²ÎÊý¡£
· IN OUT²ÎÊý£ºÕâ¸ö²ÎÊý£¬¹ý³ÌÓëÖ÷³ÌÐòË«Ïò½»Á÷Êý¾Ý¡£
Èç¹û´æ´¢¹ý³ÌÓÐOUT »òÕßIN OUT ÀàÐ͵IJÎÊý£¬ÄÇô´æ´¢¹ý³Ì¾ÍÖ»ÄÜÔÚPL/SQL
Öб»µ÷Óᣲ»ÄÜʹÓÃEXECUTE »òÕßCALLµ÷Óá£
Ò»¸öÊäÈë²ÎÊýµÄÀý×Ó
create or replace procedure proc_2(myno in number)
is emprow emp%rowtype;--¶¨ÒåÒ»¸öÐÐÀàÐ͵ıäÁ¿
begin
select * into emprow from emp where empno=myno;
dbms_output.put_line('Ô±¹¤ÐÕÃû£º'||emprow.ename||'Ô±¹¤Ð½Ë®'||emprow.sal);
end;
--µ÷ÓÃÕâ¸ö´æ´¢¹ý³Ì
begin
proc_2(7369);
end;
¼ÈÓÐÊäÈë²ÎÊý ÓÖÓÐÊä³ö²ÎÊý
create or replace procedure proc_3(myno in number,mysal out emp.sal%type, myname out emp.ename%type)
is
emprow emp%rowtype;
begin
select sal,ename into mysal,myname from emp where empno=myno;
end;
--µ÷ÓÃÕâ¸ö´æ´¢¹ý³Ì
declare
tempsal emp.sal%type;
empname emp.ename%type;
begin
proc_3(7369,tempsal,empname);
dbms_output.put_line('Ô±¹¤ÐÕÃû'||empname||'Ô±¹¤Ð½Ë®'||tempsal);
end;
Ïà¹ØÎĵµ£º
ÈçºÎÓ¦¶ÔORACLEÊý¾Ý¿âµÄ²¿·ÖÃæÊÔÌâÄ¿
1. ½âÊÍÀ䱸·ÝºÍÈȱ¸·ÝµÄ²»Í¬µãÒÔ¼°¸÷×ÔµÄÓŵã
½â´ð:Èȱ¸·ÝÕë¶Ô¹éµµÄ£Ê½µÄÊý¾Ý¿â£¬ÔÚÊý¾Ý¿âÈԾɴ¦ÓÚ¹¤×÷״̬ʱ½øÐб¸·Ý¡£¶øÀ䱸·ÝÖ¸ÔÚÊý¾Ý¿â¹Ø±Õºó£¬½øÐб¸·Ý£¬ÊÊÓÃÓÚËùÓÐģʽµÄÊý¾Ý¿â¡£Èȱ¸·ÝµÄÓŵãÔÚÓÚµ±±¸·Ýʱ£¬Êý¾Ý¿âÈԾɿÉÒÔ±»Ê¹Óò¢ÇÒ¿ÉÒÔ½«Êý¾Ý¿â»Ö¸´µ½ÈÎÒâÒ»¸öʱ¼äµã¡£À䱸· ......
¸Ðл¶ÁÕß¿´¡¶Oracle´óÐÍÊý¾Ý¿âϵͳÔÚAIXUNIXÉϵÄʵսÏê½â¡·Õâ±¾Ê飬ÕâÀï»Ø´ðһЩ¶ÁÕßÓʼþÌá³öµÄÒ»¸ö½ÏΪ¹«¹²µÄÎÊÌ⣺ASMÓÐʲôÓã¿ÎªÊ²Ã´Óã¿ ASMÊÇOracle´Ó10g¿ªÊ¼ÌṩµÄÒ»ÖÖ´æ´¢¹ÜÀí¼¼Êõ£¬Ö¸µÄÊÇÒ»¸öÔÚÎïÀí¾í£¨»òÕß´ÅÅÌ·ÖÇø£©ÉÏÌرðΪOracleÊý¾ÝÎļþ¶ø´´½¨µÄ¡°×¨Óá±Îļþϵͳ¡£¸ÃÎļþϵͳÓÉOracleÄÚºËά ......
ÔÎĵØÖ·£ºhttp://www.phontol.com/20090719_525808_1.html
1 LogMiner µÄÓÃ;
¡¡¡¡Oracle LogMiner ÊÇ Oracle¹«Ë¾´Ó²úÆ· 8iÒÔºóÌṩµÄÒ»¸öʵ¼Ê·Ç³£ÓÐÓõķÖÎö¹¤¾ß£¬Ê¹Óøù¤¾ß¿ÉÒÔÇáËÉ»ñµÃ OracleÖØ×÷ÈÕÖ¾Îļþ£¨¹éµµÈÕÖ¾Îļþ£©ÖеľßÌåÄÚÈÝ£¬ÌرðÊÇ£¬¸Ã ¹¤¾ß¿ÉÒÔ·ÖÎö³öËùÓжÔÓÚÊý¾Ý¿â²Ù×÷µÄ DML£¨insert¡¢update¡¢ ......
ORACLEûÓÐÏóSQL SERVERÖÐÒ»ÑùµÄ×ÔÔö¼Ó×ֶΣ¬ÒªÊµÏÖÖ»ÄÜͨ¹ýSEQUENCEÀ´ÊµÏÖ
1.´´½¨ÐòÁУº
create sequence your_seq
nocycle
maxvalue 9999999999
start with 1;
2.ʹÓô¥·¢Æ÷ʵÏÖ×ÔÔö£º
create or replace trigger your_seq_tri
before insert on your_table1 for each row
declare
next_id number;
begin
se ......