Hi ,
Im new to MySql and i have no idea how to convert a sql server user
defined function to MySql. Can any one help me..
CREATE FUNCTION ChildCategories (@categoryId int, @taxId int,
@dummyTaxId int)
RETURNS @retTable TABLE (path varchar(2048),
parent_id int,
category_id int,
taxonomy_id int,
checkout_user_id int)
AS
BEGIN
DECLARE ChildCatIds CURSOR
FOR
Select DISTINCT category_id
FROM E_KEW_Category
WHERE parent_id = @categoryId AND taxonomy_id = @taxId
OPEN childCatIds
DECLARE @childCatId int
FETCH NEXT FROM childCatIds INTO @childCatId
WHILE(@@FETCH_STATUS = 0)
BEGIN
IF(@childCatId IS NOT NULL)
INSERT INTO @retTable(path, parent_id, category_id, taxonomy_id,
checkout_user_id)
SELECT path, parent_id, category_id, taxonomy_id, checkout_user_id
FROM E_KEW_Category
WHERE category_id = @childCatId AND taxonomy_id = @taxId
UNION
SELECT path,parent_id,category_id, taxonomy_id, checkout_user_id
from ChildCategories( @childCatId, @taxId, @dummyTaxId)
FETCH NEXT FROM childCatIds INTO @childCatId
END
CLOSE childCatIds
DEALLOCATE childCatIds
RETURN
END
Thanks in advance
slash