Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
3 replies
Subscribers
9 subscribers
Views
2785 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
General
I'm trying to convert a number of SQL Server stored procedures into MySQL st
steveb
over 9 years ago
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
0
steveb
over 9 years ago
...` 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.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
mohamedt808
over 9 years ago
Hi Steve,
Please refer below link which states, DECLARE is permitted only inside a BEGIN ... END compound statement and must be at its start, before any other statements. Hope this helps..
(
dev.mysql.com/.../declare.html)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
steveb
over 9 years ago
Hi Mohamed
Thanks for your suggestion. I did have the BEGIN END in the SQL Server version of the proc and for some reason omitted it in the MySQL version.
I now need to find a way of doing SQL error checking without resorting to keying in every single status code MySQL can return.
Thanks
Steve
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel