I'm trying to convert a number of SQL Server stored procedures into MySQL st

I'm trying to convert a number of SQL Server stored procedures into MySQL stored procedure, which will be called using the Stored Procedure smart node. Unfortunately if I try and include error processing they fail to create a stored proc, but if I remove the error handling the stored proc is created.

An example of one of the SQL Server stored procs is:

CREATE PROCEDURE [CM].[SPUPDATEUSERID]
          @pincustomerReference varchar(20),
          @pinuserId varchar(15),
          @pinstatus int
AS
BEGIN
          -- SET NOCOUNT ON added to prevent extra result sets from interfering with INSERT statements.
          SET NOCOUNT ON;

          -- Insert statements for procedure here
          UPDATE CM.GenericDemandData
          SET userId = @pinuserId, status = @pinstatus
          WHERE customerReference = @pincustomerReference
          AND userId = ''

          IF @@ERROR <> 0
                              RETURN 1
END

MySQL version where I've attempted to put error handling in

CREATE DEFINER = `appian` @`%` PROCEDURE `CM_SPUPDATEUSERID`(
          IN `pincustomerReference...

OriginalPostID-160498

OriginalPostID-160498

  Discussion posts and replies are publicly visible

Parents
  • ...` VARCHAR(20),
              IN `pinuserId` VARCHAR(15),
              IN `pinstatus` INT
    ) NOT DETERMINISTIC MODIFIES SQL DATA SQL SECURITY DEFINER DECLARE EXIT HANDLER FOR SQLEXCEPTION SET error = 1;
    UPDATE
              GenericDemandData
    SET
              userId = pinuserId,
              status = pinstatus
    WHERE
              customerReference = pincustomerReference
              AND userId = ''

    I get the message:

    #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 'DECLARE EXIT HANDLER FOR SQLEXCEPTION
    SET
    error = 1' at line 5

    If I remove the DECLARE statement

    CREATE DEFINER = `appian` @`%` PROCEDURE `CM_SPUPDATEUSERID`(
              IN `pincustomerReference` VARCHAR(20),
              IN `pinuserId` VARCHAR(15),
              IN `pinstatus` INT
    ) NOT DETERMINISTIC MODIFIES SQL DATA SQL SECURITY DEFINER
    UPDATE
              GenericDemandData
    SET
              userId = pinuserId,
              status = pinstatus
    WHERE
              customerReference = pincustomerReference
              AND userId = ''

    The stored proc is created.
Reply
  • ...` VARCHAR(20),
              IN `pinuserId` VARCHAR(15),
              IN `pinstatus` INT
    ) NOT DETERMINISTIC MODIFIES SQL DATA SQL SECURITY DEFINER DECLARE EXIT HANDLER FOR SQLEXCEPTION SET error = 1;
    UPDATE
              GenericDemandData
    SET
              userId = pinuserId,
              status = pinstatus
    WHERE
              customerReference = pincustomerReference
              AND userId = ''

    I get the message:

    #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 'DECLARE EXIT HANDLER FOR SQLEXCEPTION
    SET
    error = 1' at line 5

    If I remove the DECLARE statement

    CREATE DEFINER = `appian` @`%` PROCEDURE `CM_SPUPDATEUSERID`(
              IN `pincustomerReference` VARCHAR(20),
              IN `pinuserId` VARCHAR(15),
              IN `pinstatus` INT
    ) NOT DETERMINISTIC MODIFIES SQL DATA SQL SECURITY DEFINER
    UPDATE
              GenericDemandData
    SET
              userId = pinuserId,
              status = pinstatus
    WHERE
              customerReference = pincustomerReference
              AND userId = ''

    The stored proc is created.
Children
No Data