我正在开发一个SQL项目。我想创建一个返回一个表的sql * Plus函数。 我已经做出这样的事情,但它不工作,我不知道为什么:在PL/SQL函数中返回表格
CREATE OR REPLACE FUNCTION changeNbPersonnes(recette IN int, nbPersonne IN int)
RETURN table_res TABLE
(
idIngredient int NOT NULL,
nomIngredient varchar(255) NOT NULL,
quantite int NOT NULL
)
AS
CURSOR curseur_etape IS
SELECT * FROM IngredientRecette ir
JOIN recette r
ON ir.idrecette=r.idrecette
JOIN ingredient i
ON ir.idingredient=i.idingredient
WHERE r.idrecette=recette;
BEGIN
FOR row_ingredient IS
INSERT INTO res(idIngredient,nomIngredient,quantite)
VALUES(
row_ingredient.idingredient,
row_ingredient.Nom,
row_ingredient.quantite
);
END FOR;
RETURN res;
END;
/
你能帮助我吗? “RETURN table_res TABLE”有问题
咦?这看起来不像有效的pl/sql styntax /代码。 – OldProgrammer
事实上,我想返回结果列表,但我发现的唯一方法是创建一个像这样的新表格 –
您应该只使用一个视图。 – itsLex