±±´óÇàÄñoracleѧϰ±Ê¼Ç25
¹ý³ÌÖеÄÊÂÎñ
¶¨Òå¹ý³Ìp1
create or replace procedure p1
as
begin
insert into student values(5,'xdh','m',sysdate);
rollback;
end;
¶¨Òå¹ý³Ìp2
create or replace procedure p2
as
begin
update student set stu_sex = 'a' where stu_id = 3;
p1;
end;
Ö´Ðйý³Ìp2
exec p2;
Ö´ÐÐÍê±Ï·¢ÏÖ±íÖÐÊý¾ÝûÓбä¸ü£¬ËµÃ÷p1ÖеÄrollbackÓï¾ä½«p2ÖеÄupdateÓï¾äÒ²»Ø¹öÁË¡£
×ÔÖ÷ÊÂÎñ´¦Àí
²½Ö裺
Ö÷ÊÂÎñ´¦ÀíÆô¶¯×ÔÖ÷ÊÂÎñ´¦Àí
Ö÷ÊÂÎñ´¦Àí±»ÔÝÍ£
×ÔÖ÷ÊÂÎñ´¦Àísql²Ù×÷
ÖÐÖ¹×ÔÖ÷ÊÂÎñ´¦Àí
»Ö¸´Ö÷ÊÂÎñ´¦Àí
pragma autonomous_transaction
ÓÃÓÚ±ê¼Ç×Ó³ÌÐò
ÔÚp1µÄas beginµ±ÖмÓÈë pragma autonomous_transaction ºóÖ´ÐУ¬·¢ÐÐp2µÄupdateÓï¾äÉúЧ£¬p1ÖеÄÊÂÎñ×÷Ϊ×ÔÖ÷ÊÂÎñÀ´´¦Àí£¬²»Ó°ÏìÖ÷ÊÂÎñ¡£
³ÌÐò°ü
Ïà¹Ø¶ÔÏóµÄ·â×°
-³ÌÐò°ü¹æ¸ñ˵Ã÷
ÉùÃ÷×Ó³ÌÐò£¬²»°üº¬ÊµÏÖ
create package °üÃû is|as ±äÁ¿ÉùÃ÷|ÀàÐͶ¨Òå|Òì³£ÉùÃ÷|ÓαêÉùÃ÷|º¯Êý˵Ã÷|¹ý³Ì˵Ã÷
pragma restrict_references(º¯ÊýÃû,WNDS[,WNPS][,RNDS][,RNPS])
end [°üÃû];
create or replace package StuPackages
is
type curRefStudent is REF CURSOR RETURN student%rowtype;
procedure insertStudent(stuid in student.stu_id%type,stuname in student.stu_name%type,stusex in student.stu_sex%type,studate in student.stu_birthday%type);
Function QueryStudent(stuid in student.stu_id%type) return student%rowtype;
end StuPackages;
-³ÌÐò°üÖ÷Ìå
¶¨Òå×Ó³ÌÐò£¬ÊµÏÖÉùÃ÷²¿·Ö
create package body °üÃû is|as ±äÁ¿ÉùÃ÷|ÀàÐͶ¨Òå|Òì³£ÉùÃ÷|ÓαêÉùÃ÷|º¯Êý¶¨Òå|¹ý³Ì¶¨Òå
end [°üÃû];
CREATE OR REPLACE
PACKAGE BODY STUPACKAGES AS
procedure insertStudent(stuid in student.stu_id%type,stuname in student.stu_name%type,stusex in student.stu_sex%type,studate in student.stu_birthday%type) AS
i INTEGER;
Student_Exist EXCEPTION;
BEGIN
select count(*) into i from student where stu_id = stuid;
if i>0 then
raise Student_Exist;
else
insert into student values(stuid,stuname,stusex,studate);
commit;
end if;
Ïà¹ØÎĵµ£º
oracle ±í½á¹¹µÄÐÞ¸Ä
½ñÌì×ܽáϹØÓÚ±íµÄÐÞ¸Ä,·ÀÖ¹ÒÔºóÍü¼Ç,ºÃ¼ÇÐÔ²»ÈçÀñÊÍ·Âð!!!
¸ü¸Ä±íµÄ½á¹¹
1.±à¼±íµÄ×Ö¶Î
ÐÞ¸ÄÒ»¸öÁеÄÊý¾ÝÀàÐÍ(Ò»°ãÏÞÓÚÐ޸ij¤¶È£¬ÐÞ¸ÄΪһ¸ö²»Í¬ÀàÐÍʱÓÐÖî¶àÏÞÖÆ):
Óï·¨:
ALTER TABLE ±íÃû MODIFY(ÁÐÃû Êý¾ÝÀàÐÍ);
eg1:
alter table ......
OracleµÄÔÚÏßÖØ¶¨Òå±í¹¦ÄÜ
http://blog.itpub.net/post/468/12855
http://blog.itpub.net/post/468/12962
ÔÚÒ»¸ö¸ß¿ÉÓÃϵͳÖУ¬Èç¹ûÐèÒª¸Ä±äÒ»¸ö±íµÄ¶¨ÒåÊÇÒ»¼þ±È½Ï¼¬ÊÖµÄÎÊÌ⣬ÓÈÆäÊǶÔÓÚ7×24ϵͳ¡£OracleÌṩµÄ»ù±¾Óï·¨»ù±¾¿ÉÒÔÂú×ãÒ»°ãÐÔÐ޸쬵«ÊǶÔÓÚ°ÑÆÕͨ¶Ñ±í¸ÄΪ·ÖÇø±í£¬°ÑË÷Òý×éÖ¯±íÐÞ¸ÄΪ¶Ñ±íµÈ²Ù×÷¾ÍÎÞ ......
ORACLE±í·ÖÇøÒÔ¼°ÐÅÏ¢²éÕÒ
http://www.sysab.cn/a/db/oracle/2009/1020/2433.html
·ÖÇø¸ÅÊö ΪÁ˼ò»¯Êý¾Ý¿â´ó±íµÄ¹ÜÀí,ÀýÈçÔÚÊý¾Ý²Ö¿âÖÐÒ»°ã¶¼ÊÇTB¼¶µÄÊýÁ¿¼¶.ORACLE8ÒÔºóÍÆ³öÁË·ÖÇøÑ¡Ïî.·ÖÇø½«±í·ÖÀëÔÚÈôÓÚ²»Í¬µÄ±í¿Õ¼äÉÏ,Ó÷ֶøÖÎÖ®µÄ·½·¨À´Ö§³ÅÔªÏÞÅòÕ͵Ĵó±í,×é´ó±íÔÚÎïÀíÒ»¼¶µÄ¿É¹ÜÀíÐÔ.½«´ó±í·Ö¸î³É½ÏСµÄ·ÖÇø¿ÉÒÔ¸ ......
×Ó³ÌÐò ÃüÃûµÄpl/sql¿é
create procedure ¹ý³ÌÃû [²ÎÊý1 in|out|in out¡]
¾Ö²¿±äÁ¿ÉùÃ÷
Ö´ÐÐÓï¾ä
in
out
in out
¹ý³ÌÃû(²ÎÊýÀï±í); create or replace
procedure add123 as
i integer;
j integer;
begin
i:=1;
j:=2;
dbms_output.put_l ......
http://tianzt.blog.51cto.com/459544/171759 ½ö½ö¹©×Ô¼ºÑ§Ï°Ö®ÓÃ
´ËÎÄ´ÓÒÔϼ¸¸ö·½ÃæÀ´ÕûÀí¹ØÓÚ·ÖÇø±íµÄ¸ÅÄî¼°²Ù×÷:
1.±í¿Õ¼ä¼°·ÖÇø±íµÄ¸ÅÄî
2.±í·ÖÇøµÄ¾ßÌå×÷ÓÃ
3 ......