mysql ÀÛ¼ÓÔËËã - ÆäËûÊý¾Ý¿â¿ª·¢ / MySQL/Postgresql
sp ³ÌÐò
delimiter //
create procedure ma()
begin
declare i int default 0;
while i<11 do
set i=i+1;
select i;
end while;
end //
delimiter ;
1+2+...+9+10
ΪʲôÕâ¸ö³ÌÐòÎÞ·¨ÊµÏÖÀÛ¼ÓЧ¹û
//Çë˵Ã÷Õâ¸ö³ÌÐòµÄȱÏݺ͸Ľø·½·¨¡£¡£Ð»Ð»¸÷λ´ó¸ç
SQL code:
mysql> call ma();
+------+
| j |
+------+
| 55 |
+------+
1 row in set (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
˳±ãÎÊÒ»ÏÂ
SQL code:
delimiter //
create procedure test07()
begin
declare i int ;
set i=1; --Õâ¸öµØ·½ÉèÖóÉi=1 ¿ÉÒÔÊäÈëµã¶«Î÷¡£¡£µ«ÊÇi=0ΪʲôÊÇÎÞÏÞÑ»·£¿
while i<10 do
set i=i+1;
select i;
end while;
end //
delimiter ;
º¹£¬Äã±¾ÉíµÄ³ÌÐòÊÇÍù±äÁ¿IÒ»Ö±ÀÛ¼Ó1¡£ ×Ðϸ¿´Ï¾ÍÃ÷°×ÁË¡£
Ïà¹ØÎÊ´ð£º
ÎÒÓõÄÊÇÁ¬½Ó³Ø×öµÄ£¬ÅäÁ¬½Ó³ØµÄ·½·¨Ó¦¸ÃûÓÐ´í£¬ÎªÊ²¾ÍÊdzöÏÖÕâÖÖÎÊÌâ
javax.servlet.ServletException: javax.naming.NameNotFoundException: No object bound to name java:comp/env/test
ÇëÎÊ´óÏÀÃÇÕâÊÇÔ ......
¸÷λÐÖµÜÇë½Ì Ï£¬ÔÚmysqlÖÐÄܲ»ÄÜʵÏÖÕâÑùÒ»¸ö¹¦ÄÜ£¬
Ò»¸ö×Ö¶ÎAÊÇ´¢´æÒ»´ó¶ÎÎÄ×ÖÄÚÈݵģ¬ÊÇÓ¢ÎÄ£¬Äܲ»ÄÜͨ¹ýMYSQLµÄ²éѯ֮ÀàµÄ¹¦ÄÜ£¬À´»ñµÃÕâ¸ö×Ö¶ÎÖÐ ³öÏÖƵÂÊ×î¸ßµÄÊ®¸öµ¥´Ê£¬²¢½«ÕâÊ®¸öµ¥´Ê×öΪеÄ×ֶδ¢´æ
a ......
ÇëÎÊ
Ìí¼ÓÐÂÊý¾ÝÔ´->Êý¾Ý¿â->Ìí¼ÓÁ¬½Ó
Õâ¸ö½çÃæÏ£¬Êý¾ÝÔ´Ñ¡Ôñ£ºMicrosoft SQL Server (SqlClient)£»
·þÎñÆ÷Ãû£º
Ó¦¸ÃдʲôÄØ£¿
ÓÐËÖªµÀ£¿¶àл¸÷λ£¡£¡
Äãµ½µ×ÊÇÒªÁ¬mysql»¹ÊÇmssql£¿
ÒýÓÃ
ÇëÎÊ
......
ÎÒÓõÄÊÇmysql6.0Ϊʲôһ´´½¨Á½¸ö±íÕâ¼äÓÃÍâ¼üÀ´Á¬½Óʱ¾Í˵´´½¨²»ÁË£ºcan"nt create table ...
ÄãµÄÓï¾äÊÇʲô£¿ÄãµÄ±íÊÇʲô´æ´¢ÒýÇ棿 Èç¹ûÊÇmyisam Ôò²»Ö§³ÖÍâ¼ü£¬ÄãÐèÒª°Ñ±í¸ÄΪinndb
貼³öSQL ......
¹òÇó½«ÒÔϺ¯Êý·ÒëΪ mysql µÄÓï·¨
CREATE FUNCTION workdayadd(
@date datetime, --»ù´¡ÈÕÆÚ
@workday int --ÒªÔö¼ÓµÄ¹¤×÷ÈÕÊý
)RETURNS datetime
AS
BEGIN
DEC ......