50%(2)1 out of 2 people found this document helpful
This preview shows page 28 - 33 out of 33 pages.
First payment: 20108 01-May-2013 24 480 First payment: 20109 01-Feb-2013 12 360 First payment: 30
109 01-Mar-2013 12 360 First payment: 30109 01-Apr-2013 12 360 First payment: 30109 01-May-2013 12 360 First payment: 30110 01-Mar-2013 12 300 First payment: 25110 01-Apr-2013 12 300 First payment: 25110 01-May-2013 12 300 First payment: 25111 01-Mar-2013 0 1500 First payment: 1500112 01-Apr-2013 12 240 First payment: 20112 01-May-2013 12 240 First payment: 20Statement processed.0.00 seconds11 – DECLARETYPE type_input1 IS RECORD (type dd_donor.typecode%TYPE,pamt dd_pledge.pledgeamt%TYPE);TYPE type_input2 IS TABLE OF type_input1INDEX BY PLS_INTEGER;tbl_input2 type_input2;CURSOR cur_pledges (p_type VARCHAR2, p_amt NUMBER ) ISSELECT firstname || ' ' || lastname Name, pledgeamtFROM dd_donor INNER JOIN dd_pledgeUSING(iddonor)WHERE typecode= p_type
AND pledgeamt > p_amt;BEGINtbl_input2(1).type := 'I';tbl_input2(1).pamt := 250;tbl_input2(2).type := 'B';tbl_input2(2).pamt := 500;FOR i IN 1..tbl_input2.COUNT LOOPFOR rec_pledges IN cur_pledges(tbl_input2(i).type,tbl_input2(i).pamt) LOOPDBMS_OUTPUT.PUT_LINE(rec_pledges.name || ' - ' ||rec_pledges.pledgeamt);END LOOP;END LOOP;END;Patrick Lee - 1200Betty Konklin - 480Mary Treanor - 360Terry Venor - 300Coastal Developers - 1500Statement processed.
0.02 seconds13 - -Declareex_donor_pk EXCEPTION;PRAGMA EXCEPTION_INIT(ex_donor_pk, -00001);BeginInsert into dd_donor(iddonor)values(302);ExceptionWhen ex_donor_pk ThenDbms_output.put_line('This ID is Already Assigned');end;This ID is Already AssignedStatement processed.0.00 seconds Please ma’am am doing this for extra marksCase projectCase 4-1.Block one is an example of user defined exception while block two is an example of a predefined exception.PL/SQL allows you to define your own exceptions according to the need of your program. A user-defined exception must be declared and then raised explicitly, using either a RAISE statement or the procedure DBMS_STANDARD.RAISE_APPLICATION_ERROR.PL/SQL provides many pre-defined exceptions, which are executed when any database rule is violated by a program. For example, the predefined exception NO_DATA_FOUND is raised when a SELECT INTO statement returns no rows.
CASE_NOT_FOUND. It is raised when none of the choices in the WHEN clauses of a CASE statement is selected, and there is no ELSE clause.4-2Alter table mm_movieADD stk_flag varchar2(5)Table altered.0.04 secondsDeclareCursor cur_inv isSelect * from mm_movieFor update nowait;BeginFor rec_inv in cur_inv loopif rec_inv.stk_flag >= 75 thenupdate mm_movieset stk_flag = '*';Elseupdate mm_movieSet stk_flag =''where current of cur_inv;End if;end loop;end;
1 row(s) updated.0.01 seconds
You've reached the end of your free preview.
Want to read all 33 pages?
Spring '16
Mary Gable
Salary, Annual Salary, Stored procedure, new salary