CREATE OR REPLACE
PROCEDURE deleteProcFood(id IN food_item.R_ID%TYPE,
item_name IN food_item.ITEM_NAME%TYPE)IS
BEGIN
DELETE FROM food_item
WHERE food_item.R_ID = id AND
food_item.ITEM_NAME = item_name;
COMMIT;
END;
/
这是通过匹配两个属性值进行删除的过程,但它通过仅匹配R_ID来删除值。在这里,与AND之后的值匹配不起作用。如何解决这个问题?
答案 0 :(得分:1)
检查是否有效:
CREATE OR REPLACE
PROCEDURE deleteProcFood(PIN_ID IN food_item.R_ID%TYPE,
PIN_item_name IN food_item.ITEM_NAME%TYPE)IS
BEGIN
DELETE FROM food_item
WHERE food_item.R_ID = PIN_ID AND
food_item.ITEM_NAME = PIN_item_name;
COMMIT;
END;
/
我怀疑ITEM_NAME = ITEM_NAME
是否总是返回true。因此尝试更改参数变量名称。
答案 1 :(得分:0)
优良作法是始终为所有内容添加别名,例如:
CREATE OR REPLACE
PROCEDURE deleteProcFood(id IN food_item.R_ID%TYPE,
item_name IN food_item.ITEM_NAME%TYPE)IS
BEGIN
DELETE FROM food_item
WHERE food_item.R_ID = deleteProcFood.id AND
food_item.ITEM_NAME = deleteProcFood.item_name;
COMMIT;
END;
/