SELECT id FROM books WHERE description IS NULL OR CHAR_LENGTH(description) < 10 Here is a simple example of how to use two cursors in the same routine: DELIMITER $$ĭECLARE rowCountDescription INT DEFAULT 0 INSERT INTO users_friends (user_id, friend_id) VALUES(inUserId, tempFriendId) IF tempFriendId != 0 AND tempId != 0 THEN SELECT user_id FROM users_friends WHERE user_id = tempFriendId OR friend_id = tempFriendId SELECT id FROM users WHERE email = inFriendEmail ĭECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1 DROP PROCEDURE IF EXISTS addNewFriend ĬREATE PROCEDURE addNewFriend(IN inUserId INT UNSIGNED, IN inFriendEmail VARCHAR(80))ĭECLARE tempFriendId INT UNSIGNED DEFAULT 0 Any other routine solution than this one would be great as well. It takes the id of the current user and the email of the friend we want to add as a friend, then it checks if the email has a corresponding user id and if no friend relation exists it will create one. The routine is used for adding a friend in my webapp. How can I use two cursors in the same routine? If I remove the second cursor declaration and fetch loop everthing works fine.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |