Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2008
    Posts
    6

    Unanswered: 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

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    yes, there are probably several people who can assist you

    what is your question? where are you having trouble?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •