mssql server 数据库教程存储过程转换成mysql教程数据库
DELIMITER $$
DROP PROCEDURE IF EXISTS ChangeSequence$$
CREATE PROCEDURE ChangeSequence
(
_sign INT ,-- 0: 上移 1:下移
TableName VARCHAR(50) ,-- 表名
ItemName VARCHAR(50) ,-- 主键字段名
ItemID INT , -- 主键ID
SortName VARCHAR(50) , -- 排序ID
TypeName VARCHAR(50) , -- 分类字段名
TypeValue VARCHAR(50) -- 分类值
)
BEGIN
DECLARE _SQL VARCHAR(4000);
DECLARE ThisSort INT;
DECLARE PREVID INT;
DECLARE NextID INT;
DECLARE _Count INT;CREATE TEMPORARY TABLE _Tab
(
_ItemID INT,
_Sort INT
);
SET _SQL=CONCAT('INSERT INTO _Tab (_ItemID,_Sort) SELECT ' ,ItemName,SortName,' FROM ',TableName) ;IF (TypeName<>'' AND TypeValue<>'') THEN
SET _SQL=CONCAT(_SQL,' where ',TypeName,'=',TypeValue);
END IF;
SET _SQL = CONCAT(_SQL,' ORDER BY _Sort ASC ') ;
SET @v_sql=_SQL;
PREPARE stmt FROM @v_sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
SET _SQL = '';
首页 1 2 末页