日期:2014-05-18  浏览次数:20732 次

数据库移植
需要将如下的SQLSERVER的存储过程变为MySQL的 求大师帮忙修改
首先是四张表

CREATE TABLE bbs_Users(
UID int auto_increment primary key not null,

  Uname varchar(20) not null,
Upassword varchar(20) not null,
Uemail varchar(50) not null,
Usex varchar(2) not null,
UregDate timestamp not null default now(),
Upoint int not null default 0,
Uaddress varchar(50) not null default '保密',
Uadmin int not null default 0,
Ucount int not null default 0
)auto_increment=1;
CREATE TABLE bbs_Reply(
RID int auto_increment primary key not null,
RTID int not null,
RUID int not null,
Rtitle varchar(50) NULL,
Rtext varchar(7000) not null,
Rtime timestamp not null default now(),
RdelFlag int not null
)auto_increment=1;
CREATE TABLE bbs_Section(
SID int auto_increment primary key not null,
Sname varchar(50) not null,
Sprofile varchar(100) not null,
StopicCount int not null default 0,
SallCount int not null default 0,
Smanage int NULL ,
SSID int not null default 0
)auto_increment=1;
CREATE TABLE bbs_Topic(
TID int auto_increment primary key not null,
TSID int not null,
TUID int not null,
Ttitle varchar(100) not null,
Ttext varchar(7000) not null,
Ttime timestamp not null default current_timestamp,
TreplyCount int not null default 0,
TdelFlag int not null default 0,
TlastTime timestamp not null
)auto_increment=1;

然后是存储过程 不过是SQLServer版的 希望改成MySQL版本的
------------------------------------------------------------------------
CREATE procedure PROC_addTopic
@sid int,
@uid int,
@title varchar(100),
@text varchar(7000),
@result int output
as
BEGIN TRANSACTION
DECLARE @err int
SET @err=0
INSERT INTO bbs_Topic(TSID,TUID,Ttitle,Ttext) VALUES(@sid,@uid,@title,@text)
set @err = @@error + @err
UPDATE bbs_Users SET Ucount=Ucount+1,Upoint=Upoint+2 WHERE UID=@uid
set @err = @@error + @err
UPDATE bbs_Section SET StopicCount=StopicCount+1,SallCount=SallCount+1 WHERE SID=@sid
set @err = @@error + @err
IF @err <> 0
BEGIN
  SET @result = 0
  ROLLBACK TRANSACTION
END
ELSE
BEGIN
  SET @result = 1
  COMMIT TRANSACTION
END
——————————————————————————————————————————————————————

------解决方案--------------------
LZ这个发到mysql版里,来的比较快哦。 

------解决方案--------------------
探讨

LZ这个发到mysql版里,来的比较快哦。