如何将以下代码转换为与 MySQL 一起使用?我对 MySQL 有点熟悉,但对 SQL Server 不熟悉。
create procedure spInsertAccount
(
@AccountID INT,
@InUse bit,
@IsBanned bit,
@IsPremium bit,
@IsGolden bit,
@Username VARCHAR(20),
@Password VARCHAR(20),
@Email VARCHAR(65),
@LoggedInID INT,
@CreateDate DATETIME
)
AS
BEGIN TRANSACTION
IF NOT EXISTS( SELECT * FROM Accounts WHERE AccountID = @AccountID)
BEGIN
INSERT INTO Accounts
values(@AccountID,@InUse,@IsBanned,@IsPremium,@IsGolden,@Username,@Password,@Email,@LoggedInID,@CreateDate)
select @@IDENTITY as [NewAccountID]
END
IF @@ERROR = 1
ROLLBACK TRANSACTION
ELSE
COMMIT TRANSACTION
GO