Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The Brewbeans\' manager wants to have a file extracted from the database contain

ID: 3914144 • Letter: T

Question

The Brewbeans' manager wants to have a file extracted from the database containing product information for inventory and cash flow analysis. The manager uses this file in spreadsheet software on a laptop computer. Using the UTL_FILE package, create a PL/SQL block that places data columns in a comma-delimited text file named prod_ext.txt in the c:oraclass directory. The extracted file should contain one line per product and the following columns of the BB_PRODUCT table: IDPRODUCT, PRODUCTNAME, PRICE, TYPE, STOCK, ORDERED and REORDER.

BB_PRODUCT TABLE

IDPRODUCTPRODUCTNAME PRICETYPESTOCKORDEREDREORDER I CapressoBar Model #351 2 Capresso Ultima 3 Eileen 4-cup 4 Coffee Grinder 5 Sumatra 6 Guatamala 7 Columbia 8 Brazil 9 Ethiopia 99.99 E 129.99 E 32. 5E 28.5 E 10.5 C 10 C 10.8 C 10.8 C 10 C 10 C 23 15 30 26 41 42 61 53 54 50 15 25 45 35 35 35 35 French Press 10 10 Espresso 50

Explanation / Answer

create or replace procedure CopyData is
ftype utl_file.file_type;
begin
ftype :=utl_file.fopen(dir, filename, 'W'=
);
for c in (select IDPRODUCT, PRODUCTNAME, PRICE, TYPE, STOCK, ORDERED,REORDER from BB_PRODUCT) loop
utl_file.put_line(ftype, c.IDPRODUCT||','||c.PRODUCTNAME||','||PRICE||','||TYPE||','||STOCK||','||ORDERED||','||REORDER);
end loop;
utl_file.fclose(ftype);
end;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote