Commit 11a680eb authored by michael lundquist's avatar michael lundquist
Browse files

Adding week 11 stuff

parent 58fb1f3b
/**
Part I, problems 5-5 to 5-9 (five hands on problems) for Chapter 5 given in the textbook.
*/
/**
5-5
make a procedure named STATUS_SHIP_SP that:
Runs when orders are shipped so employees can add the shipping information, the date shipped to bb_basketstatus
*/
CREATE OR REPLACE
PROCEDURE STATUS_SHIP_SP
(p_bask_id IN BB_BASKETSTATUS.IDBASKET%TYPE,
p_ship_date IN BB_BASKETSTATUS.DTSTAGE%TYPE,
p_notes IN BB_BASKETSTATUS.NOTES%TYPE,
p_shipper IN BB_BASKETSTATUS.SHIPPER%TYPE,
p_track IN BB_BASKETSTATUS.SHIPPINGNUM%TYPE
)
AS
begin
INSERT INTO BB_BASKETSTATUS (IDSTATUS, IDBASKET, IDSTAGE, DTSTAGE, NOTES, SHIPPER, SHIPPINGNUM) VALUES ( BB_STATUS_SEQ.NEXTVAL, p_bask_id, 3, p_ship_date, p_notes, p_shipper, p_track);
end;
/
begin
--print basket status
for status in ( select * from bb_basketstatus ) loop
dbms_output.put_line( 'status: ' || status.IDSTATUS || ' basket: ' || status.IDBASKET || ' stage: ' || status.IDSTAGE || ' date: ' || status.DTSTAGE || ' notes: ' || status.NOTES || ' shipper: ' || status.SHIPPER || ' shippingnum: ' || status.SHIPPINGNUM
);
end loop;
STATUS_SHIP_SP(3, SYSDATE, 'hello world', 'mike', 'track num');
--print basket status
for status in ( select * from bb_basketstatus ) loop
dbms_output.put_line( 'status: ' || status.IDSTATUS || ' basket: ' || status.IDBASKET || ' stage: ' || status.IDSTAGE || ' date: ' || status.DTSTAGE || ' notes: ' || status.NOTES || ' shipper: ' || status.SHIPPER || ' shippingnum: ' || status.SHIPPINGNUM
);
end loop;
end;
/
begin
STATUS_SHIP_SP(3, SYSDATE, 'hello world', 'mike', 'track num');
end;
/**
5-6
return a string representing a basket's status
*/
CREATE OR REPLACE
PROCEDURE STATUS_SP
(p_bask_id IN BB_BASKETSTATUS.IDBASKET%TYPE,
p_stage OUT VARCHAR(20))
IS
cursor lv_cursor is SELECT select * from (select idstatus from bb_basketstatus order by dtstage) b where rownum <= 1;
lv_idstatus bb_basketstatus.idstatus%TYPE;
begin
open lv_cursor;
if lv_cursor%notfound then
p_stage := 'nothing found';
else
fetch lv_cursor into lv_idstatus;
case lv_idstatus
when 1 THEN p_stage := 'Submitted and received'
when 2 THEN p_stage := 'Confirmed, processed, sent to shipping'
when 3 THEN p_stage := 'Shipped'
when 4 THEN p_stage := 'Cancelled'
when 5 THEN p_stage := 'Back-ordered'
end case;
end if;
close lv_cursor;
end;
/
DECLARE
lv_str VARCHAR2(40) := '';
begin
STATUS_SP(3, lv_str);
DBMS_OUTPUT.put_line( lv_str );
end;
/
select * from (select idstatus from bb_basketstatus order by dtstage) b where rownum <= 1;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment