请看下面,
mysql> show procedure status ;
+--------+-------+-----------+----------------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+
| Db | Name | Type | Definer | Modified | Created | Security_type | Comment | character_set_client | collation_connection | Database Collation |
+--------+-------+-----------+----------------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+
| nasdaq | inc | PROCEDURE | root@localhost | 2010-08-04 19:43:31 | 2010-08-04 19:43:31 | DEFINER | | latin1 | latin1_swedish_ci | latin1_swedish_ci |
| nasdaq | sCode | PROCEDURE | root@localhost | 2010-08-04 23:53:49 | 2010-08-04 23:53:49 | DEFINER | | latin1 | latin1_swedish_ci | latin1_swedish_ci |
+--------+-------+-----------+----------------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+
2 rows in set (0.04 sec)mysql> drop procedure inc;
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '��' at line 1
mysql> drop procedure inc;
Query OK, 0 rows affected (0.00 sec)mysql> drop procedure sCode;
Query OK, 0 rows affected (0.00 sec)mysql> source /home/pt/test.sql;
Query OK, 0 rows affected (0.00 sec)mysql> call sCode();
-> ;
-> q
-> quit
-> ;
-> ^CCtrl-C -- exit!
Aborted
pt@pt-laptop:~$
我的mysql控制台,最近总是出现问题,明明命令输入完了,按下回车键,mysql出现-》标记,不立即执行,我只能按下ctr+c退出到shell,重新进入mysql,请问,问题出在哪里?
mysql> show procedure status ;
+--------+-------+-----------+----------------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+
| Db | Name | Type | Definer | Modified | Created | Security_type | Comment | character_set_client | collation_connection | Database Collation |
+--------+-------+-----------+----------------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+
| nasdaq | inc | PROCEDURE | root@localhost | 2010-08-04 19:43:31 | 2010-08-04 19:43:31 | DEFINER | | latin1 | latin1_swedish_ci | latin1_swedish_ci |
| nasdaq | sCode | PROCEDURE | root@localhost | 2010-08-04 23:53:49 | 2010-08-04 23:53:49 | DEFINER | | latin1 | latin1_swedish_ci | latin1_swedish_ci |
+--------+-------+-----------+----------------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+
2 rows in set (0.04 sec)mysql> drop procedure inc;
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '��' at line 1
mysql> drop procedure inc;
Query OK, 0 rows affected (0.00 sec)mysql> drop procedure sCode;
Query OK, 0 rows affected (0.00 sec)mysql> source /home/pt/test.sql;
Query OK, 0 rows affected (0.00 sec)mysql> call sCode();
-> ;
-> q
-> quit
-> ;
-> ^CCtrl-C -- exit!
Aborted
pt@pt-laptop:~$
我的mysql控制台,最近总是出现问题,明明命令输入完了,按下回车键,mysql出现-》标记,不立即执行,我只能按下ctr+c退出到shell,重新进入mysql,请问,问题出在哪里?
估计这个文件中有DELIMITER重置。
create procedure conmax()
begin
declare icode varchar(10);
declare cur_conmax cursor for (select symbol from quote group by symbol);
declare exit HANDLER for not found close cur_conmax;
create table tempTable select * from test.quote where symbol='YHOO';
delete from tempTable;
open cur_conmax;
repeat
fetch cur_conmax into icode;
set @sql = concat(' insert into tempTable select * from `',icode,'` order by close desc limit 5 ;');
PREPARE stmt1 FROM @sql;
EXECUTE stmt1 ;
DEALLOCATE PREPARE stmt1;
until 0 end repeat;
close cur_conmax;
end;
$$
请问,哪句话是重置呢?
create procedure conmax()
begin
declare icode varchar(10);
declare cur_conmax cursor for (select symbol from quote group by symbol);
declare exit HANDLER for not found close cur_conmax;
create table tempTable select * from test.quote where symbol='YHOO';
delete from tempTable;
open cur_conmax;
repeat
fetch cur_conmax into icode;
set @sql = concat(' insert into tempTable select * from `',icode,'` order by close desc limit 5 ;');
PREPARE stmt1 FROM @sql;
EXECUTE stmt1 ;
DEALLOCATE PREPARE stmt1;
until 0 end repeat;
close cur_conmax;
end;
$$
delimiter ;
create procedure conmax()
begin
。。
end;
$$
delimiter ; --最后写完存储过程 要改回来