Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

oracle PL/SQL FOR UPDATE Óë FOR UPDATE OFµÄÇø±ð

PL/SQL-FOR UPDATE Óë FOR UPDATE OFµÄÇø±ð
url:http://hi.baidu.com/1413/blog/item/a521251f7e5993c4a686696b.html
Êý¾Ý¿â oracle for update of   ºÍ   for updateÇø±ð    
select * from TTable1 for update Ëø¶¨±íµÄËùÓÐÐУ¬Ö»ÄܶÁ²»ÄÜд
2 select * from TTable1 where pkid = 1 for update Ö»Ëø¶¨pkid=1µÄÐÐ
3 select * from Table1 a join Table2 b on a.pkid=b.pkid for update Ëø¶¨Á½¸ö±íµÄËùÓмǼ
4 select * from Table1 a join Table2 b on a.pkid=b.pkid where a.pkid = 10 for update Ëø¶¨Á½¸ö±íµÄÖÐÂú×ãÌõ¼þµÄÐÐ
5. select * from Table1 a join Table2 b on a.pkid=b.pkid where a.pkid = 10 for update of a.pkid Ö»Ëø¶¨Table1ÖÐÂú×ãÌõ¼þµÄÐÐ
for update ÊÇ°ÑËùÓÐµÄ±í¶¼Ëøµã for update of ¸ù¾Ýof ºó±íµÄÌõ¼þËø¶¨Ïà¶ÔÓ¦µÄ±í
-----------
¹ØÓÚNOWAIT(Èç¹ûÒ»¶¨ÒªÓÃFOR UPDATE£¬ÎÒ¸ü½¨Òé¼ÓÉÏNOWAIT)
µ±ÓÐLOCK³åͻʱ»áÌáʾ´íÎó²¢½áÊøSTATEMENT¶ø²»ÊÇÔÚÄÇÀïµÈ´ý(±ÈÈç:Òª²éµÄÐÐÒѾ­±»ÆäËüÊÂÎñËøÁË,µ±Ç°µÄËøÊÂÎñÓëÖ®³åÍ»,¼ÓÉÏnowait,µ±Ç°µÄÊÂÎñ»á½áÊø»áÌáʾ´íÎó²¢Á¢¼´½áÊø STATEMENT¶ø²»Ôٵȴý).
Èç¹û¼ÓÁËfor updateºó ¸ÃÓï¾äÓÃÀ´Ëø¶¨Ìض¨µÄÐУ¨Èç¹ûÓÐwhere×Ӿ䣬¾ÍÊÇÂú×ãwhereÌõ¼þµÄÄÇЩÐУ©¡£µ±ÕâЩÐб»Ëø¶¨ºó£¬ÆäËû»á»°¿ÉÒÔÑ¡ÔñÕâЩÐУ¬µ«²»Äܸü¸Ä»òɾ³ýÕâЩÐУ¬Ö±µ½¸ÃÓï¾äµÄÊÂÎñ±»commitÓï¾ä»òrollbackÓï¾ä½áÊøΪֹ¡£
ÒòΪFOR   UPDATE×Ó¾ä»ñµÃÁËËø£¬ËùÒÔCOMMIT½«ÊÍ·ÅÕâЩËø¡£µ±ËøÊÍ·ÅÁË£¬¸ÃÓαê¾ÍÎÞЧÁË¡£


Ïà¹ØÎĵµ£º

Oracle PL/SQLÖÐÈçºÎʹÓÃ%TYPEºÍ%ROWTYPE

¡¡
¡¡¡¡1. ʹÓÃ%TYPE
¡¡¡¡ÔÚÐí¶àÇé¿öÏ£¬PL/SQL±äÁ¿¿ÉÒÔÓÃÀ´´æ´¢ÔÚÊý¾Ý¿â±íÖеÄÊý¾Ý¡£ÔÚÕâÖÖÇé¿öÏ£¬±äÁ¿Ó¦¸ÃÓµÓÐÓë±íÁÐÏàͬµÄÀàÐÍ¡£ÀýÈ磬students±íµÄfirst_nameÁеÄÀàÐÍΪVARCHAR2(20),ÎÒÃÇ¿ÉÒÔ°´ÕÕÏÂÊö·½Ê½ÉùÃ÷Ò»¸ö±äÁ¿£º
¡¡¡¡DECLARE
¡¡¡¡ v_FirstName VARCHAR2(20);
¡¡
¡¡µ«ÊÇÈç¹ûfirst_nameÁеĶ¨Òå¸Ä±äÁ ......

¹ØÓÚSQLÒìµØ±¸·ÝµÄ·½·¨

·½°¸Ò»£ºSQL×Ô´øµÄÊý¾Ý¿â±¸·Ý¼Æ»®
Ò»£º»ù±¾Ë¼Â·
1£ºÒªÊµÏÖÒìµØ±¸·Ý£¬±ØÐëʹÓÃÓòÓû§ÕʺÅÀ´Æô¶¯SQL Server·þÎñÒÔ¼°SQL Server Agent·þÎñ£¬ÒòΪ±¾µØϵͳÕÊ»§ÎÞ·¨·ÃÎÊÍøÂç¡£
2£ºÔÚÒìµØ»úÆ÷Öн¨Á¢Ò»¸öÓëSQL Server·þÎñÆ÷ÖÐÆô¶¯SQL Server·þÎñµÄÓòÓû§ÕʺÅͬÃûÕʺÅ,ÇÒÃÜÂë±£³ÖÏàͬ¡£ÔÚÒìµØ»úÆ÷Öн¨Á¢Ò»¸ö¹²ÏíÎļþ¼Ð£¬²¢ÉèÖÃºÏ ......

sql´æ´¢¹ý³ÌѧϰʵÀý

ʲôÊÇ´æ´¢¹ý³ÌÄØ£¿
¡¡¡¡¶¨Ò壺
¡¡¡¡½«³£ÓõĻòºÜ¸´ÔӵŤ×÷£¬Ô¤ÏÈÓÃSQLÓï¾äдºÃ²¢ÓÃÒ»¸öÖ¸¶¨µÄÃû³Æ´æ´¢ÆðÀ´, ÄÇôÒÔºóÒª½ÐÊý¾Ý¿âÌṩÓëÒѶ¨ÒåºÃµÄ´æ´¢¹ý³ÌµÄ¹¦ÄÜÏàͬµÄ·þÎñʱ,Ö»Ðèµ÷ÓÃexecute,¼´¿É×Ô¶¯Íê³ÉÃüÁî¡£
¡¡¡¡½²µ½ÕâÀï,¿ÉÄÜÓÐÈËÒªÎÊ£ºÕâô˵´æ´¢¹ý³Ì¾ÍÊÇÒ»¶ÑSQLÓï¾ä¶øÒÑ°¡£¿
¡¡¡¡Microsoft¹«Ë¾ÎªÊ²Ã´»¹ÒªÌí¼ÓÕ ......

SqlÓï¾ä

Update  Channel set Unit ='mg' ,
RunUpThreshold='10' ,
RunDownThreshold='10' ,
SafetyUpThreshold='10' ,
SafetyDownThreshold='10' 
where Bridge='001' and DeviceCode='AS'
and SensorCode='001' and Supplement='N'
set  £º ','
where: and ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ