My procedure in short:
/* Procedure: GET_TREE */
BEGIN
CREATE TEMPORARY TABLE `TestTABLE`
(category_id INT unsigned, category_parent_id INT unsigned) ENGINE=MEMORY;
/* Do some stuff like retrieve the values (recursive loop etc, into vchild and aparent)
/* Inserting it into temp table */
INSERT INTO `TestTABLE` VALUES (vchild_category_id, aparent_category_id);
SELECT * FROM `TestTABLE`
END
It is working perfect and gets the result, so when I call it:
CALL GET_TREE(1);
It will nicely output the tree I want.
However, NOW I want to use these values as a TABLE, as following:
SELECT cc.category_id, cd.name, visible, protect
FROM GET_TREE(?) cc
LEFT JOIN categorydesc cd ON (cc.category_id = cd.category_id)
This is what I did in FireBird before, which is not working in MySQL of course. So I tried to d it like this:
CALL GET_TREE(1);
SELECT cc.category_id, cd.name, visible, protect
FROM `TestTABLE`
LEFT JOIN categorydesc cd ON (cc.category_id = cd.category_id)
But that leaves me with an error and saying the table is empty. Even though it is in the same session.
And lastly I tried:
SET @arr= GET_TREE(1);
SELECT @arr;
But that is of course also not working.
Anyone any ideas? I just want to use the values coming out the procedure as a table or another way. I do NOT want to loop trough all the values seperately, that might take forever, depending on the tree size of course.
Thanks!