create helper procedure to insert an item

This commit is contained in:
Peter Kofler 2014-04-13 15:21:47 +02:00
parent 1ad3fcd95e
commit 66495cb872
2 changed files with 20 additions and 12 deletions

9
plsql/new_item.sql Normal file
View File

@ -0,0 +1,9 @@
CREATE OR REPLACE PROCEDURE new_item(
i_name item.name%TYPE,
i_sell_in item.sell_in%TYPE,
i_quality item.quality%TYPE)
IS
BEGIN
INSERT INTO item (name, sell_in, quality) VALUES (i_name, i_sell_in, i_quality);
END new_item;
/

View File

@ -1,17 +1,5 @@
DELETE FROM item;
INSERT INTO item (name, sell_in, quality) VALUES ('+5 Dexterity Vest', 10, 20);
INSERT INTO item (name, sell_in, quality) VALUES ('Aged Brie', 2, 0);
INSERT INTO item (name, sell_in, quality) VALUES ('Elixir of the Mongoose', 5, 7);
INSERT INTO item (name, sell_in, quality) VALUES ('Sulfuras, Hand of Ragnaros', 0, 80);
INSERT INTO item (name, sell_in, quality) VALUES ('Sulfuras, Hand of Ragnaros', -1, 80);
INSERT INTO item (name, sell_in, quality) VALUES ('Backstage passes to a TAFKAL80ETC concert', 15, 20);
INSERT INTO item (name, sell_in, quality) VALUES ('Backstage passes to a TAFKAL80ETC concert', 10, 49);
INSERT INTO item (name, sell_in, quality) VALUES ('Backstage passes to a TAFKAL80ETC concert', 5, 49);
-- this conjured item does not work properly yet ;
INSERT INTO item (name, sell_in, quality) VALUES ('Conjured Mana Cake', 3, 6);
COMMIT;
DECLARE
l_days NUMBER(3);
CURSOR c_items IS
@ -20,6 +8,17 @@ DECLARE
BEGIN
DBMS_OUTPUT.PUT_LINE('OMGHAI!');
new_item('+5 Dexterity Vest', 10, 20);
new_item('Aged Brie', 2, 0);
new_item('Elixir of the Mongoose', 5, 7);
new_item('Sulfuras, Hand of Ragnaros', 0, 80);
new_item('Sulfuras, Hand of Ragnaros', -1, 80);
new_item('Backstage passes to a TAFKAL80ETC concert', 15, 20);
new_item('Backstage passes to a TAFKAL80ETC concert', 10, 49);
new_item('Backstage passes to a TAFKAL80ETC concert', 5, 49);
-- this conjured item does not work properly yet ;
new_item('Conjured Mana Cake', 3, 6);
l_days := 2;
FOR i IN 0 .. l_days - 1