Question

In: Computer Science

Create a PL/SQL block to retrieve and display data for all pledges made in a specified...


Create a PL/SQL block to retrieve and display data for all pledges made in a specified month. One row of output
should be displayed for each pledge. Include the following in each row of output:
  
- Pledge ID, donor ID, and Pledge Amount
- If the pledge is being paid in a lump sum, display "LUMP SUM".
- If the pledge is being paid in monthly payments, display "Monthly - #" (With the # representing the number
of months for payment).

Solutions

Expert Solution

Solution:

PL/SQL Code:

SET SERVEROUTPUT ON

DECLARE

PLEDGES DD_PLEDGE%ROWTYPE;

START_MONTH_DATE DD_PLEDGE.PLEDGEDATE%TYPE := '01-OCT-12';

END_MONTH_DATE DD_PLEDGE.PLEDGEDATE%TYPE := '31-OCT-12';

BEGIN

FOR PLEDGES IN

(SELECT IDPLEDGE, IDDONOR, PLEDGEAMT, CASE

WHEN PAYMONTHS = 0 THEN 'Lump Sum.'

ELSE 'Monthly - ' || PAYMONTHS

END AS MONTHLY_PAYMENT

FROM DD_PLEDGE

WHERE PLEDGEDATE >= START_MONTH_DATE AND PLEDGEDATE <= END_MONTH_DATE

ORDER BY PAYMONTHS)

LOOP

DBMS_OUTPUT.PUT_LINE('Pledge ID: ' || PLEDGES.IDPLEDGE || ', Donor ID: '

|| PLEDGES.IDDONOR || ', Pledge Amount: ' ||to_char(PLEDGES.PLEDGEAMT,

'$9999.99') || ', Monthly Payments: ' || PLEDGES. MONTHLY_PAYMENT);

END LOOP;

END;

------------------------------------------------------------------------------------------------------------------------------------------------------

anonymous block completed

Pledge ID: 102, Donor ID: 310, Pledge Amount: $500.00, Monthly Payments: Lump Sum.

Pledge ID: 103, Donor ID: 307, Pledge Amount: $2000.00, Monthly Payments: Lump Sum.

Pledge ID: 106, Donor ID: 301, Pledge Amount: $75.00, Monthly Payments: Lump Sum.

Pledge ID: 105, Donor ID: 309, Pledge Amount: $120.00, Monthly Payments: Monthly - 12

Pledge ID: 104, Donor ID: 308, Pledge Amount: $240.00, Monthly Payments: Monthly - 12

Pledge ID: 107, Donor ID: 302, Pledge Amount: $1200.00, Monthly Payments: Monthly – 24

------------------------

desc DD_PLEDGE;

SELECT IDPLEDGE, IDDONOR, PLEDGEAMT, PAYMONTHS,

CASE WHEN PAYMONTHS = 0 THEN 'Lump Sum.'

ELSE 'Monthly - ' || PAYMONTHS

END AS MONTHLY_PAYMENT

FROM DD_PLEDGE

--WHERE PLEDGEDATE >= START_MONTH_DATE AND PLEDGEDATE <= END_MONTH_DATE

ORDER BY PAYMONTHS

IDPLEDGE IDDONOR PLEDGEAMT PAYMONTHS MONTHLY_PAYMENT   

---------- ---------- ---------- ---------- --------------------------------------------------

100 303 80 0 Lump Sum.

101 304 35 0 Lump Sum.

102 310 500 0 Lump Sum.

103 307 2000 0 Lump Sum.

106 301 75 0 Lump Sum.

111 306 1500 0 Lump Sum.

112 309 240 12 Monthly - 12   

109 301 360 12 Monthly - 12

110 303 300 12 Monthly - 12   

105 309 120 12 Monthly - 12   

104 308 240 12 Monthly - 12   

107 302 1200 24 Monthly - 24   

108 308 480 24 Monthly - 24

13 rows selected

--------------------------------------------------

#please consider my effort and give me a like...thank u...


Related Solutions

Using SQL Developer Question 1 Create a block to retrieve and display pledge and payment information...
Using SQL Developer Question 1 Create a block to retrieve and display pledge and payment information for a specific donor. For each pledge payment from the donor, display the pledge ID, pledge amount, number of monthly payments, payment date, and payment amount. The list should be sorted by pledge ID and then by payment date. For the first payment made for each pledge, display “first payment” on that output row. Question 2 Redo question 1, but use a different cursor...
PL/SQL Write a PL/SQL block, using a While Loop, to calculate and print the sum of...
PL/SQL Write a PL/SQL block, using a While Loop, to calculate and print the sum of the odd integers from 10 to 120 inclusive. (Hint: 11 + 13 + 15 + . . . + 97 + 99)
PL/SQL Write a PL/SQL block, using a Case Statement that prints a student’s letter     grade...
PL/SQL Write a PL/SQL block, using a Case Statement that prints a student’s letter     grade based on the value stored in a variable called grade. Use the ACC      grading system described in the course syllabus to create the block and set     the initial value of grade as 95. Use only one print statement and no      logical operators in your code. Assume a grade can exceed 100, but it      can’t be negative. Grade Scale: Grade Scale:...
Assignment 2- 9   USING A FOR LOOP Create a PL/SQL block using a FOR loop to...
Assignment 2- 9   USING A FOR LOOP Create a PL/SQL block using a FOR loop to generate a payment schedule for a donor’s pledge, which is to be paid monthly in equal increments. The values variable for the block is starting payment due date, monthly payment amount, and a number of total monthly payments for the pledge. The list that’s generated should display a line for each monthly payment showing payment number, date due, payment amount, and donation balance (remaining...
ORACLE TASK 2-2 USING A FOR LOOP Create a PL/SQL block using a FOR loop to...
ORACLE TASK 2-2 USING A FOR LOOP Create a PL/SQL block using a FOR loop to generate a payment schedule for a donor’s pledge, which is to be paid monthly in equal increments. Values variable for the block are starting payment due date, monthly payment amount and number of total monthly payments for the pledge. The list that’s generated should display a line for each monthly payment showing payment number, date due, payment amount, and donation balance (remaining amount of...
Utilize the Outdoor Clubs & Product database to create a PL/SQL anonymous block program unit that...
Utilize the Outdoor Clubs & Product database to create a PL/SQL anonymous block program unit that lists the product_name attribute value and a demand status text display. The demand status text display is determined by counting the number of times a product has been ordered so far. The demand status text display will be either “Low Demand” or “High Demand”. Low Demand is displayed if the product has been ordered less than 2 times. High Demand is displayed if the...
Create a PL/SQL anonymous block that uses a nested loop (inner loop 1 to 15; outer...
Create a PL/SQL anonymous block that uses a nested loop (inner loop 1 to 15; outer loop 1 to 5) to perform computations using the SQL functions, ABS, EXP, SQRT, ROUND, MIN, MAX, LOG, MOD, REMAINDER and POWER The outer loop will use the functions, ABS, EXP, SQRT, ROUND to display the following messages (must be “ The absolute value of <outer loop index> is <value>” “ The value of e to the <outer loop index> power is <value>” “...
Use the following information to create SQL commands to retrieve data from Henry Books database :...
Use the following information to create SQL commands to retrieve data from Henry Books database : For each book, list the book code, book title, publisher code, and publisher name. Order the results by publisher name. For each book published by Plume, list the book code, book title, and price. List the book title, book code, and price of each book published by Plume that has a book price of at least $14. List the book code, book title, and...
Create Procedure in (PL/SQL) called Make_Account (v_first, v_last, v_email, v_errormsg) Add a new user to the...
Create Procedure in (PL/SQL) called Make_Account (v_first, v_last, v_email, v_errormsg) Add a new user to the Account table. If the new user cannot be added, return a error message. Table Account (this is the table I need to add data using PROCEDURE) Account_no (PK) Email (VARCHAR2) first (VARCHAR2) last (VARCHAR2)
How to display in SQL Server, for example, all the author First Names are FIVE LETTERS...
How to display in SQL Server, for example, all the author First Names are FIVE LETTERS LONG if I have the Author Table. I used the WHERE LENGTH ua_fname=5   This is not returning names with 5 letters. Can someone please suggest to me the correct one?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT