Question

PL/SQL gap-fill question:

For the following stored procedure, please fill in the missing information in the underlined areas:


create or replace procedure get_items_shipped_capt as

cursor list_items(cid in captain.capt_id%type) is
select item.item_no,_____________________ ,weight from item,shipment_line,shipment
where item.item_no = ____________________________ and shipment_line.shipment_id = shipment.shipment_id and shipment.capt_id = ___________;
cursor all_captains is
select capt_id
from captain;
TB constant char(1) := CHR(9);
begin
for cp in _____________ loop

dbms_output.put_line(Captain ID: '||cp.capt_id); dbms_output.new_line;
dbms_output.put_line('Item Number'||TB||'Description'||TB||'Weight');

dbms_output.put_line('=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ =+=+');

for det in list_items(______________) loop

dbms_output.put_line(det.item_no||TB||det.description||TB|| det.weight);

end loop; dbms_output.new_line; end loop;

end;

The following pictures are for reference only, not sure if it has anything to do with this question.

captain ship ship_no ship class capacity purch date 09 manufacturer_id shipment SHIPMENT ID SHIP_NO CAPT ID SHIPMENT DATE ORI

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The blanks are marked in bold.


create or replace procedure get_items_shipped_capt as

cursor list_items(cid in captain.capt_id%type) is
select item.item_no, item.description , item.weight from item,shipment_line,shipment
where item.item_no = shipment_line.item_no and shipment_line.shipment_id = shipment.shipment_id and shipment.capt_id = cid;

cursor all_captains is
select capt_id
from captain;
TB constant char(1) := CHR(9);
begin
for cp in all_captains loop

dbms_output.put_line('Captain ID: '||cp.capt_id); dbms_output.new_line;
dbms_output.put_line('Item Number'||TB||'Description'||TB||'Weight');

dbms_output.put_line('=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ =+=+');

for det in list_items(1234) loop

dbms_output.put_line(det.item_no||TB||det.description||TB|| det.weight);

end loop; dbms_output.new_line; end loop;

end;

  1. item_no is selected from the table item.
  2. Then, in second blank: two tables item and shipment_line are joined using common column 'item_no'. Therefore, item.item_line=shipment_line.item_no
  3. In third blank, whatever captain id is accepted by cursor will be assigned to shipment.capt_id. Therefore, shipment.capt_id=cid;
  4. Now run a loop for all the data in cursor all_captains. Hence in 4th blank we will write: for cp in all_captains
  5. In 5th block pass the(required) value of captain id to the cursor.
Add a comment
Know the answer?
Add Answer to:
PL/SQL gap-fill question: For the following stored procedure, please fill in the missing information in the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • PL/SQL Auction Program 1. Create a user xyz, who is the owner of the auction. Create...

    PL/SQL Auction Program 1. Create a user xyz, who is the owner of the auction. Create the schema, and package. 2. Create users x1 and x2 who are the participants in the auction. They will need acces to the package. 3. Bid on the same item and record your observations. Verify all scenarios. Upload the files with the missing code and a detailed sample run. AUCTION OWNER.TXT SQL> conn / as sysdba Connected. SQL> drop user xyz cascade; User dropped....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT