|
@@ -3,8 +3,12 @@ $$
|
|
|
DECLARE
|
|
|
proCursor CURSOR FOR SELECT pro_id FROM Product;
|
|
|
proId Product.pro_id%TYPE;
|
|
|
+
|
|
|
warCursor CURSOR FOR SELECT war_id FROM Warehouse;
|
|
|
warId Warehouse.war_id%TYPE;
|
|
|
+
|
|
|
+ stoCursor CURSOR FOR SELECT sto_quantity FROM Stock WHERE pro_id = proId AND war_id = warId;
|
|
|
+ stoQuantity Stock.sto_quantity%TYPE;
|
|
|
BEGIN
|
|
|
RAISE NOTICE 'Start';
|
|
|
|
|
@@ -19,7 +23,18 @@ BEGIN
|
|
|
LOOP
|
|
|
FETCH warCursor INTO warId;
|
|
|
EXIT WHEN warId IS NULL;
|
|
|
- RAISE NOTICE 'Pro % for war %', proId, warId;
|
|
|
+
|
|
|
+ -- Find associated storage
|
|
|
+ OPEN stoCursor;
|
|
|
+ FETCH stoCursor INTO stoQuantity;
|
|
|
+ IF stoQuantity IS NULL
|
|
|
+ THEN
|
|
|
+ RAISE NOTICE 'Pro % for war % not available', proId, warId;
|
|
|
+ ELSE
|
|
|
+ RAISE NOTICE 'Pro % for war % stores %', proId, warId, stoQuantity;
|
|
|
+ END IF;
|
|
|
+ CLOSE stoCursor;
|
|
|
+
|
|
|
END LOOP;
|
|
|
CLOSE warCursor;
|
|
|
END LOOP;
|