If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > convert stored procedure from Mssql to Mysql

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-10-08, 05:00
reetha reetha is offline
Registered User
 
Join Date: Jul 2008
Posts: 6
convert stored procedure from Mssql to Mysql

hi there. can someone assist me to convert the following stored proc into Mysql stored proc
Code:
/****** Object:  Stored Procedure spBanner_d    

Script Date: 18/06/2008 3:31:18 PM ******/




CREATE  PROCEDURE spBanner_d
(
@BannerID int,
@title nvarchar(256),
@userID nvarchar(20)
)
AS
/*
if exists(SELECT * FROM tblBannerAd WHERE 

bannerIdRef = @BannerID)
  UPDATE tblBanner SET isDeleted = 1 WHERE 

BannerID=@BannerID
else
  DELETE from tblBanner WHERE BannerID=@BannerID
*/
Declare @logdesc as nvarchar(256)

BEGIN TRANSACTION
  -- to delete all banner ads belong to banner
  DELETE from tblBannerAd WHERE 

BannerIDRef=@BannerID

  IF @@error<>0
    BEGIN
      ROLLBACK TRANSACTION
      RAISERROR 13002 'Error delete banner 

advertisement from banner, please try again.'
      RETURN '1'  --indicate there is error
    END

  set @logdesc = 'Delete Banner Ads from Banner : 

' + convert(nvarchar,@BannerID) + '/' + 

convert(nvarchar,@title)
  Execute spLog_I 'spBanner_d','Delete',@logdesc, 

@UserID

 
  set @logdesc = 'Delete Banner: ' + 

convert(nvarchar,@BannerID) + '/' + 

convert(nvarchar,@title)
  Execute spLog_I 'spBanner_d','Delete',@logdesc, 

@UserID

  IF @@error<>0
    BEGIN
      ROLLBACK TRANSACTION
      RAISERROR 13002 'Error update to audit 

trail, please try again.'
      RETURN '1'  --indicate there is error
    END
  ELSE
     COMMIT TRANSACTION

/*
if @@Error<>0
  Return -1
else
  Return 0
*/

GO
Reply With Quote
  #2 (permalink)  
Old 07-10-08, 07:20
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
yes, there are probably several people who can assist you

what is your question? where are you having trouble?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On