Need help with Stored Procedure coding after migration from SQL Server
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 ;
Subject
Views
Written By
Posted
Need help with Stored Procedure coding after migration from SQL Server
2420
February 11, 2013 09:07AM
970
February 11, 2013 11:46AM
894
February 11, 2013 07:12PM
1062
February 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.