首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > Mysql >

mysql创建存储过程的一个有关问题,待

2012-02-04 
mysql创建存储过程的一个问题,在线等待!mysql5表结构如下:存储方式为innodbtable:bug(id(自动增加,主键,in

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;

热点排行