日期:2014-05-16  浏览次数:20770 次

mysql创建存储过程的一个问题,在线等待!
mysql   5
表结构如下:存储方式为innodb
table   :
bug(id(自动增加,主键,int),name   char(50),note   char(50))
file(bid   int   foreign   key(bid)   references   bug(id),filename   char(50))
创建存储过程如下:

create   proc   upproc
(@name   char(50),@note   char(50))
as
declare   @id   int
begin
insert   into   bug(name,note)
values(@name,@note)

select   @id=@@IDENTITY
insert   into   file(bid,filename)  
select   @id,@note
end
go

错误如下:
MySQL   返回:  

#1064   -   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   'proc   upproc
(@name   char(50),@note   char(50))
as
declare   @id   int
begin
insert '   at   line   1  


------解决方案--------------------
预制语句的SQL语法基于三个SQL语句:

PREPARE stmt_name FROM preparable_stmt;

EXECUTE stmt_name [USING @var_name [, @var_name] ...];

{DEALLOCATE | DROP} PREPARE stmt_name;