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¡£ ×Ðϸ¿´Ï¾ÍÃ÷°×ÁË¡£
Ïà¹ØÎÊ´ð£º
ÇëÎÊÏÂÄܲ»ÄÜÔÙwindows϶¨ÆÚÇå¿ÕmysqlÒ»¸ö±íÖеÄÈ«²¿Êý¾Ý£¬ÓÃPHPʵÏÖ£¡
лл¸÷λÁË
¾Í±ÈÈçÒ»¸öÐÇÆÚÇå¿ÕÒ»´Î
±ÈÈçÿ¸öÐÇÆÚÁùÁãµãÇå¿ÕÒ»´Î£¡
ллÁË
¼Æ»®ÈÎÎñ...php....sql...truncate....OK
Äã¾ÍÕâ½ÓÔÚҳà ......
ÏÈÉÏ´íÎó
ÎÞ·¨Áª½ÓÊý¾Ý¿â
java.sql.SQLException: Before start of result set
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)
at com.mysql.jdbc.ResultSet.checkRowPos(ResultSet.java: ......
ÎÒ¾õµÃmysqlºÍsqlserverÓй²Í¬µÄµØ·½£º
ÓиöÎÊÌâÊǹØÓÚ±íµÄËøÎÊÌ⣺
½ø³ÌA ½ø³ÌB
select * from user where id in lock share mode£¨¹²ÏíËø)
&nb ......
SELECT * from alarms where id in (select resource_id from res_products where product=22)
Õâ¸öÓï¾äÔÚmysqlÖÐΪʲô²»ÄÜÖ´ÐУ¿ÎÒµÄmysqlÊý¾Ý¿âÊÇ5.0.27°æ±¾µÄ£¡
Èç¹ûʵÔÚ²»ÐÐÄÇô¸ÃÓøöʲôÓï¾ä´úÌæЧÂʸü¸ßÄØ ......
Java code:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was51093 seconds ago.The last packet sent successfully to the server was 5 ......