צפיות
תשובות
בעיית stored procedure ב-MYSQL
שלום לכולם, יש לי כאן פרוצדורה עם בעיית סינטאקס כלשהיא. ואני לא מוצא מה הבעיה בקוד.
אני אשמח אם מישהו שמבין ב-MYSQL יעיף מבט ויאמר לי מה קורה פה :
DELIMITER $$
CREATE DEFINER=`btUser`@`localhost` PROCEDURE `Notifications_GetByUserId`(
IN SiteId int,
IN UserId int,
IN FirstId int,
IN LastId int
)
BEGIN
declare tmpId1 int ;
declare tmpId2 int;
declare cur CURSOR FOR select uida,uidb from usersfriendship where siteId = SiteId and approved = 1 and (uida = UserId or uidb = UserId);
CREATE TEMPORARY TABLE IF NOT EXISTS tmpUsers (
userId int,
PRIMARY KEY (`userId`)
) ENGINE=MEMORY ;
open cur;
loopUsers: loop
fetch cur into tmpId1,tmpId2;
if tmpId1 = UserId then insert into tmpUsers (userId) values (tmpId1);
if tmpId2 = UserId then insert into tmpUsers (userId) values (tmpId2);
end loop loopUsers;
close cur;
END
0 תשובות