11.07.2015 Views

Oracle Database 11 g - Online Public Access Catalog

Oracle Database 11 g - Online Public Access Catalog

Oracle Database 11 g - Online Public Access Catalog

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER <strong>11</strong> ■ APPLICATION DEVELOPMENT 473BEGINtmp.donation_id:=donation_id;tmp.donor_name:=doner_name;tmp.donation_amount:=donation_amount;tmp.address_1:=address_1;tmp.address_2:=address_2;tmp.address_3:=address_3;tmp.city:=city;tmp.state:=state;tmp.postal_code:=postal_code;tmp.country:=country;tmp.phone:=phone;tmp.email:=email;return tmp;END;BEGINdonArr.EXTEND;donArr(donArr.LAST):=newDonRec_t(donations_s.nextval,'John Q <strong>Public</strong>',100,'101 Main St.',null,null,'Anytown','ST','0000000','US','<strong>11</strong>1-555-3333','jqpublic@email.net');donArr.EXTEND;donArr(donArr.LAST):=newDonRec_t(donations_s.nextval,'Percival Lowell',200,'100 Cactus Ln',null,null,'Flagstaff','AZ','86001','US','928-555-0000','plowell@email.net');donArr.EXTEND;donArr(donArr.LAST):=newDonRec_t(donations_s.nextval,'Jane Doe',400,'101 Elm',null,null,'Peaceville','ST','0000000','US','333-555-2222','jdoe@email.net');-- insert the recordsFORALL I IN 1..donArr.COUNTINSERT INTO donations VALUES donArr(i);END;/The function newDonRec_t() initializes a record of type donations%RECTYPE. When thisblock is executed, the same result is seen. However, when you change Jan Doe’s donationamount to –400 as before, the following is emitted:ORA-20001: Donations must be positiveORA-06512: at "DEMO.DONATION_INS_TRG", line 17ORA-04088: error during execution of trigger 'DEMO.DONATION_INS_TRG'ORA-06512: at line 36Donor: John Q <strong>Public</strong> Amount: 100Donor: Percival Lowell Amount: 200

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!