Commit 491ed592 authored by michael lundquist's avatar michael lundquist
Browse files

done with week 11 pp

parent cd1ef595
...@@ -53,59 +53,139 @@ end; ...@@ -53,59 +53,139 @@ end;
return a string representing a basket's status return a string representing a basket's status
*/ */
CREATE OR REPLACE CREATE OR REPLACE
PROCEDURE STATUS_SP PROCEDURE STATUS_SP
(p_bask_id IN BB_BASKETSTATUS.IDBASKET%TYPE, (p_bask_id IN BB_BASKETSTATUS.IDBASKET%TYPE,
p_stage OUT VARCHAR(20)) p_stage OUT VARCHAR2
IS )
cursor lv_cursor is SELECT select * from (select idstatus from bb_basketstatus order by dtstage) b where rownum <= 1; AS
lv_idstatus bb_basketstatus.idstatus%TYPE; lv_cursor SYS_REFCURSOR;
TYPE stat_type IS RECORD ( status bb_basketstatus.idstatus%TYPE);
lv_idstatus stat_type;
begin begin
open lv_cursor; OPEN lv_cursor FOR select idstatus from bb_basketstatus where IDBASKET = p_bask_id order by dtstage;
if lv_cursor%notfound then if lv_cursor%notfound then
p_stage := 'nothing found'; p_stage := 'Nothing found';
else else
fetch lv_cursor into lv_idstatus; fetch lv_cursor into lv_idstatus;
case lv_idstatus case lv_idstatus.status
when 1 THEN p_stage := 'Submitted and received' when 1 THEN p_stage := 'Submitted and received';
when 2 THEN p_stage := 'Confirmed, processed, sent to shipping' when 2 THEN p_stage := 'Confirmed, processed, sent to shipping';
when 3 THEN p_stage := 'Shipped' when 3 THEN p_stage := 'Shipped';
when 4 THEN p_stage := 'Cancelled' when 4 THEN p_stage := 'Cancelled';
when 5 THEN p_stage := 'Back-ordered' when 5 THEN p_stage := 'Back-ordered';
end case; end case;
end if; end if;
close lv_cursor; close lv_cursor;
end STATUS_SP; end STATUS_SP;
/ /
DECLARE
lv_str VARCHAR2(40) := '';
begin
STATUS_SP(3, lv_str);
DBMS_OUTPUT.put_line( '4 ' || lv_str );
STATUS_SP(4, lv_str);
DBMS_OUTPUT.put_line( '6 ' || lv_str );
end;
/
/**
5-7
give customers who haven't shopped since
update BB_PROMOLIST
update PROMOTION for the month the deals take effect
*/
CREATE OR REPLACE CREATE OR REPLACE
PROCEDURE STATUS_SP PROCEDURE PROMO_SHIP_SP (
(p_bask_id IN BB_BASKETSTATUS.IDBASKET%TYPE cutoff in date,
p_stage OUT VARCHAR(20) month in BB_PROMOLIST.month%TYPE,
year in BB_PROMOLIST.year%TYPE,
flag in BB_PROMOLIST.promo_flag%TYPE
) as
begin
INSERT INTO BB_PROMOLIST (IDSHOPPER, MONTH, YEAR, PROMO_FLAG, USED) select idshopper, month, year, flag, 'N' from bb_shopper where dtentered < cutoff;
end PROMO_SHIP_SP;
/
begin
PROMO_SHIP_SP(TO_DATE('15-FEB-12'), 'APR', '2012', '1');
end;
/
/**
5-8
Adds an item to BB_BASKETITEM
*/
create or REPLACE
PROCEDURE BASKET_ADD_SP (
PROD_ID IN BB_BASKETITEM.IDPRODUCT%TYPE,
PRC IN BB_BASKETITEM.PRICE%TYPE,
QTY IN BB_BASKETITEM.QUANTITY%TYPE,
BASK_ID IN BB_BASKETITEM.IDBASKET%TYPE,
SIZE_CODE IN BB_BASKETITEM.OPTION1%TYPE,
FORM_CODE IN BB_BASKETITEM.OPTION2%TYPE
) )
AS AS
lv_idstatus bb_basketstatus.idstatus%TYPE;
lv_cursor SYS_REFCURSOR;
begin begin
dbms_output.put_line( 'hi' ); INSERT INTO BB_BASKETITEM ( IDBASKETITEM, IDPRODUCT, PRICE, QUANTITY, IDBASKET, OPTION1, OPTION2 ) VALUES
end STATUS_SP; (BB_IDBASKETITEM_SEQ.NEXTVAL, PROD_ID, PRC, QTY, BASK_ID, SIZE_CODE, FORM_CODE);
COMMIT;
--IDBASKET IS GENERATED?
end;
/ /
--p_bask_id IN BB_BASKETSTATUS.IDBASKET%TYPE
--
--lv_cursor SYS_REFCURSOR;
/*
p_stage OUT VARCHAR2(20)
OPEN lv_cursor FOR SELECT select * from (select idstatus from bb_basketstatus order by dtstage) b where rownum <= 1;
p_stage := 'hi';
close lv_cursor;
*/
begin
BASKET_ADD_SP(8, 10.8, 1, 14, 1, 4);
end;
/
/**
5-9
CHECKS THE UN/PW
AND RETURNS THE MEMBER NAME AND A COOKIE VALUE
IF THE COMBO IS VALID.
IF IT'S INVALID, SAY SO IN p_check
*/
create or REPLACE
procedure MEMBER_CK_SP (
UN in BB_SHOPPER.USERNAME%TYPE,
PW in out VARCHAR,
p_check out VARCHAR2
)
AS
lv_cur SYS_REFCURSOR;
TYPE rec_type IS RECORD ( name VARCHAR (40));
lv_val rec_type;
begin
open lv_cur for select FIRSTNAME || ' ' || LASTNAME || ' ' || COOKIE from bb_shopper where PASSWORD = PW AND USERNAME = UN;
FETCH lv_cur INTO lv_val;
PW := lv_val.name;
close lv_cur;
if PW is null THEN
p_check := 'INVALID';
end if;
end;
/
DECLARE DECLARE
lv_str VARCHAR2(40) := ''; lv_pw varchar(50) := 'kile';
lv_pcheck varchar(50) := '';
begin begin
STATUS_SP(3, lv_str); MEMBER_CK_SP('rat55', lv_pw, lv_pcheck);
DBMS_OUTPUT.put_line( lv_str ); dbms_output.put_line( lv_pw );
dbms_output.put_line( lv_pcheck );
MEMBER_CK_SP('rat', lv_pw, lv_pcheck);
dbms_output.put_line( lv_pw );
dbms_output.put_line( lv_pcheck );
end; end;
/ /
\ No newline at end of file
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