PL/SQLÖÐGOTOÓï¾äºÍ±êÇ©
ÔÚPL/SQLÖÐÒ²ÌṩGOTOÓï¾ä,ÆäÓï·¨ÊÇ
GOTO label;
ÕâÀïlabelÊÇÔÚPL/SQL¿éÖж¨ÒåµÄ±êÇ©.±êÇ©ÊÇÓÃË«¼ýÍ·À¨ºÅÀ¨ÆðÀ´µÄ.µ±Ö´ÐÐGOTOÓï¾äµÄʱºò,¿ØÖÆ»áÁ¢¼´×ªµ½ÓɱêÇ©±êʶµÄÓï¾ä.
1.¶ÔÓÚGOTOµÄÏÞÖÆ
a.¶ÔÓÚ¿é,Ñ»·»òÕßIFÓï¾ä¶øÑÔ,ÏëÒª´ÓÍâ²ãÌøµ½ÄÚ²ãÊÇ·Ç·¨µÄ.
b.ʹÓÃGOTO×Ó¾ä´ÓÒ»¸öIF×Ó¾äÌøµ½ÁíÒ»¸ö×Ó¾äÖÐÒ²ÊÇ·Ç·¨µÄ.
begin
if x>3 then
...
goto<<lbl>>
else
<<lbl>>
...
end if;
end;
c.´ÓÒ»¸öÒì³£´¦Àí¿éÄÚÌøתµ½µ±Ç°¿éÊÇ·Ç·¨µÄ¡£
2.Ϊѻ·É趨±êÇ©
Ñ»·±¾ÉíÊÇ¿ÉÒÔ±»É趨±êÇ©µÄ¡£Èç¹û½øÐÐÁËÉ趨£¬ÄÇô¿ÉÒÔÔÚEXITÓï¾äÖÐʹÓøñêÇ©Ö¸Ã÷ÒªÍ˳öÄĸöÑ»·.ÀýÈç:
<<l_outer>>
for v_outer_index in 1..10 loop
...
<<I_inner>>
for v_inner_index in 1..30 loop
...
if v_outer_index > 5 then
EXIT I_outer;
end if;
end loop I_inner;
end loop I_outer;
Èç¹ûÑ»·É趨Á˱êÇ©£¬ÄÇô¿ÉÒÔÔÚEND LOOPÓï¾äµÄºóÃæ°üº¬¸Ã±êÇ©Ãû,ÈçÉÏÃæËùʾ.
3.½÷É÷µÄʹÓÃGOTOÓï¾ä
ÔÚʹÓÃGOTOÓï¾äʱһ¶¨ÒªÐ¡ÐÄ,²»È»¶¼ÊÇЩÌøÀ´ÌøÈ¥µÄ´úÂë,ºÜÄÑÀí½âÒ²ºÜÄÑά»¤.
¼¸ºõËùÓÐʹÓÃGOTOµÄÇé¿ö¶¼¿ÉÒÔʹÓÃÆäËûµÄPL/SQL¿ØÖƽṹ,ÀýÈçÑ»·»òÕßÌõ¼þ½á¹¹,À´ÖØнøÐбàд.Ò²¿ÉÒÔʹÓÃÒì³£´¦ÀíÀ´Í˳öÉî²ãǶÌ×µÄÑ»·,¶ø²»ÓÃÖ±½ÓÌøתµ½½áβ.
4.nullÓï¾ä
ÔÚһЩÇé¿öÏÂ,Äã¿ÉÄÜÏëÒªÏÔʽµÄÖ¸Ã÷²»½øÐÐÈκβÙ×÷.Õâ¿ÉÒÔͨ¹ýʹÓÃNULLÓï¾äÀ´ÊµÏÖ.NULLÓï¾ä²»×öÈκÎÊÂÇé,ËüÖ»ÊÇÒ»¸öռλ·û.
ÀýÈç:
begin
...
if ... then
...
else
null;
end if;
...
end;
Ïà¹ØÎĵµ£º
import java.sql.*;
/*
* JAVAÁ¬½ÓACCESS£¬SQL Server,MySQL,OracleÊý¾Ý¿â
*
* */
public class JDBC {
public static void main(String[] args)throws Exception {
Connection conn=null;
//====Á¬½ÓACCESSÊý¾Ý¿â ......
1¡¢½Ø¶ÏÈÕÖ¾£º
backup log Êý¾Ý¿â with no_log
»ò£º
Çå¿ÕÈÕÖ¾
DUMP TRANSACTION ¿âÃû WITH NO_LOG
2¡¢ & ......
µ±OracleÊý¾Ý¿â´´½¨Íê³Éºó£¬ÏµÍ³½«»á×Ô¶¯ÔËÐÐutlrp.sqlÕâ¸ö½Å±¾Îļþ£¨D:\oracle\product\10.1.0\Db_1\RDBMS\ADMIN£©£¬µ«ÊÇ£¬µ±Í¨¹ý¶¨ÖÆ°²×°ÀàÐ͵ķ½Ê½´´½¨ÁËÊý¾Ý¿âʱ£¬ÏµÍ³Ôò²»»áÔËÐÐutlrp.sqlÕâ¸ö½Å±¾£¬ËùÒÔ£¬½¨ÒéÔÚ´´½¨¡¢¸üлòǨÒÆÒ»¸öÊý¾Ý¿âºó£¬ÔËÐÐÒ»ÏÂutlrp.sqlÕâ¸ö½Å±¾£¬ÒÔÑéÖ¤Êý¾Ý¿â°²×°ÊÇ·ñ³É¹¦£¬ÕâÑù¿ÉÒÔÖØбàÒë ......
1.²éѯµÄÄ£ºýÆ¥Åä
¾¡Á¿±ÜÃâÔÚÒ»¸ö¸´ÔÓ²éѯÀïÃæʹÓà LIKE '%parm1%'—— ºìÉ«±êʶλÖõİٷֺŻᵼÖÂÏà¹ØÁеÄË÷ÒýÎÞ·¨Ê¹Óã¬×îºÃ²»ÒªÓÃ.
½â¾ö°ì·¨:
ÆäʵֻÐèÒª¶Ô¸Ã½Å±¾ÂÔ×ö¸Ä½ø£¬²éѯËٶȱã»áÌá¸ß½ü°Ù±¶¡£¸Ä½ø·½·¨ÈçÏ£º
a¡¢ÐÞ¸Äǰ̨³ÌÐò——°Ñ²éѯÌõ¼þµÄ¹©Ó¦ÉÌÃû³ÆÒ»À¸ÓÉÔÀ´µÄÎı¾ÊäÈë¸ÄΪÏÂÀÁб ......
/*µÚ¼¸Ò³±ØÐë´óÓÚ1
select top ÿҳÊýÁ¿ * id
from @t a
where id not in
(select top (µÚ¼¸Ò³-1)*ÿҳÊýÁ¿ id
from @t b
)
*/
declare @lcSqlCommand nvarchar(100)
declare @t table (id int IDENTITY,orderDate datetime)
insert into @t
select orderDate
&nb ......