-2
我有一個名爲Dvdrental的數據庫,在那個數據庫中有一個名爲public.film_not_in_stock的函數,但我不明白它的作用。不知道這個功能是什麼
-- Function: public.film_not_in_stock(integer, integer)
-- DROP FUNCTION public.film_not_in_stock(integer, integer);
CREATE OR REPLACE FUNCTION public.film_not_in_stock(
IN p_film_id integer,
IN p_store_id integer,
OUT p_film_count integer)
RETURNS SETOF integer AS
$BODY$
SELECT inventory_id
FROM inventory
WHERE film_id = $1
AND store_id = $2
AND NOT inventory_in_stock(inventory_id);
$BODY$
LANGUAGE sql VOLATILE
COST 100
ROWS 1000;
ALTER FUNCTION public.film_not_in_stock(integer, integer)
OWNER TO postgres;
看起來像檢查廣告資源,以查看電影的ID是否出現在給定商店ID中。有什麼困惑呢? – duffymo
但是之後它做了什麼?因爲這是一個功能,它必須做些什麼? –
一個函數(在Postgres使用的意義上)需要一些輸入,並返回一些輸出,並可能還有副作用。在這種情況下,輸入是參數'p_film_id'和'p_store_id',輸出是該'SELECT'語句的結果。 – IMSoP