G
gzbxmcx
Unregistered / Unconfirmed
GUEST, unregistred user!
1.转换MYSQL语法,转换错误函数如下: 错误提示: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 'return(TmpDays); end' at line 1 CREATE Function GetSatOrSunDay (Types int, SDates varchar(10), Edates varchar(10)) Returns int begin declare TmpDays int; select (case DAYOFWEEK('2009-02-28') When 7 then 1 else 0 end + IF(((datediff('2009-08-31', '2008-02-22')/7) - (datediff('2009-08-31', '2008-02-22') div 7)) > 0, datediff('2009-08-31', '2008-02-22') div 7 + 1, datediff('2009-08-31', '2008-02-22') div 7)) as tempfield FROM tempdata INTO TmpDays; return(TmpDays); end; 2.SQL Server视图转MYSQL视图,附上SQL Server视图如下,那位好心人帮我转一下: 错误提示: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 'ON PatrolLine.LineID = PatrolDay.Line_ID AND PatrolLine_Dot.Line' at line 16SELECT PatrolDay.PatrolerNo, PatrolDay.EvtTime, PatrolDay.DueTime, PatrolDay.FactTime, PatrolDay.ErrorMinute, PatrolDay.Flag, PatrolDay.Work_ID, PatrolDay.ID, PatrolLine.LineName, PatrolType.TypeName, PatrolLine_Dot.LineDotID, PatrolLine.LineID, USERS.UserName, DOOR.DoorName, PatrolDot.DcuID, PatrolDot.DoorAddr, USERS.Dept_ID AS DeptID, DEPT.DeptNameFROM PatrolLine_Dot INNER JOIN PatrolLine ON PatrolLine_Dot.Line_id = PatrolLine.LineID LEFT OUTER JOIN PatrolDot ON PatrolLine_Dot.DcuID = PatrolDot.DcuID AND PatrolLine_Dot.DoorAddr = PatrolDot.DoorAddr RIGHT OUTER JOIN PatrolType INNER JOIN USERS INNER JOIN PatrolDay ON USERS.UserNo = PatrolDay.PatrolerNo ON PatrolType.ID = PatrolDay.Flag INNER JOIN DEPT ON USERS.Dept_ID = DEPT.ID ON PatrolLine.LineID = PatrolDay.Line_ID AND PatrolLine_Dot.LineDotID = PatrolDay.LineDot_ID LEFT OUTER JOIN DOOR ON PatrolDot.DcuID = DOOR.DcuID AND PatrolDot.DoorAddr = DOOR.DoorAddr 3.触发器--错误提示-->"Not allowed to set autocommit from a stored function or trigger" CREATE DEFINER='root'@`localhost` TRIGGER `PatrolLineInsertA` AFTER INSERT ON `PatrolLine` FOR EACH ROW BEGIN SET AUTOCOMMIT = 0; START TRANSACTION; if not Exists(Select LineGroupID From PatrolLineGroup Where LineGroupID = NEW.LineGroup_ID) THEN rollback work; else commit; END IF; END;