Skip navigation links

MySQL Forums :: Stored Procedures :: Need help with Stored Procedure coding after migration from SQL Server


Advanced Search

Need help with Stored Procedure coding after migration from SQL Server
Posted by: tcee sutton ()
Date: February 11, 2013 09:07AM

I am migrating my stored procedure from SQL SERVER to MYSQL and although my code doesn't cause any errors when I execute, I feel something is wrong with the code as it is not working as it should.

Can someone take a look at this code and see if there are any coding issues? Thank you in advance for your help.

MYSQL SERVER STORED PROCEDURE:
USE `a7itm`;

DELIMITER $$
SET SQL_MODE = ANSI_QUOTES$$
/****** Object: StoredProcedure [a7user].[toggleConstraintsState] Script Date: 02/07/2013 19:23:08 ******/
DROP PROCEDURE IF EXISTS a7user_toggleConstraintsState;
CREATE PROCEDURE `a7user_toggleConstraintsState`(
`toggleState` bit,
`sql`VARCHAR(1000),
`constraintName` varchar(100),
`tableName` varchar(100)
)
BEGIN
DECLARE referentialConstraints Cursor FOR SELECT tc.constraint_name,tc.table_name from INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc;
SET `sql` = 'ALTER TABLE ' + `tableName` + ' NOCHECK CONSTRAINT ' + `constraintName`;
SET `sql` = 'ALTER TABLE ' + `tableName` + ' WITH CHECK CHECK CONSTRAINT ' + `constraintName`;
Open referentialConstraints;

constraint_loop:While (FETCH_STATUS =0) DO
Fetch referentialConstraints INTO `constraintName`, `tableName`;
IF (toggleState = 0) THEN
LEAVE constraint_loop;

END IF;
END WHILE;

CLOSE referentialConstraints;

END$$
DELIMITER ;

Options: ReplyQuote


Subject Views Written By Posted
Need help with Stored Procedure coding after migration from SQL Server 1209 tcee sutton 02/11/2013 09:07AM
Re: Need help with Stored Procedure coding after migration from SQL Server 439 Peter Brawley 02/11/2013 11:46AM
Re: Need help with Stored Procedure coding after migration from SQL Server 438 tcee sutton 02/11/2013 07:12PM
Re: Need help with Stored Procedure coding after migration from SQL Server 490 Rick James 02/20/2013 10:47PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.