MySQL Forums
Forum List  »  Stored Procedures

Re: Stored Procedure Returning Multiple Rows
Posted by: marc jeeves
Date: November 30, 2019 02:30PM

i Figured it out i need to use a procedure instead of a function

thanks

Madaxe

CREATE DEFINER=`root`@`localhost` PROCEDURE `test`(
IN `NumberOfObjectIDs` INT
)
LANGUAGE SQL
DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
COMMENT ''
BEGIN
DECLARE next_val int(11);
DECLARE i int;

CREATE TEMPORARY TABLE
IF NOT EXISTS
lekodata.TempTable (objectid int);

DELETE FROM lekodata.TempTable;

SET i = 0;

loop_loop: LOOP

SET i = i + 1;
IF i <= NumberOfObjectIDs THEN
INSERT INTO lekodata.TempTable SELECT lekodata.NextObjectID(1);
ITERATE loop_loop;
END IF;
LEAVE loop_loop;

END LOOP loop_loop;
SELECT OS.objectid FROM lekodata.TempTable OS;

END

Options: ReplyQuote


Subject
Views
Written By
Posted
1426
November 30, 2019 12:45PM
Re: Stored Procedure Returning Multiple Rows
388
November 30, 2019 02:30PM


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.