【发布时间】:2018-04-10 03:39:19
【问题描述】:
我正在处理一个 SQL 项目。我想创建一个返回表的 sql*Plus 函数。 我做了这样的东西,但它不起作用,我不知道为什么:
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 语法/代码。
-
事实上我想返回一个结果列表,但我发现的唯一方法是创建一个这样的新表
-
你应该只使用视图。
-
您能否提供表 r 和 ir 的(相关)列的列表(和类型)?请解释如何处理输入参数 nbPersonne?