Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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 available 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, due date, payment amount, and donation balance(remaining amount of pledge ,owed).

Each payment will be 1 line of output displayed on the screen. For each payment made, you need to display the payment number, date due, payment amount and donation balance all on the same line. Format the dollar amounts and dates using the TO_CHAR function before they are displayed. You will utilize the ADD_MONTHS function in your code to determine the next payment date.

This is the code I have, however I am getting errors please help:

DECLARE num_of_pmt NUMBER(2); pmt_num NUMBER(2); start_date DATE; due_date DATE; mth_pmt_amt NUMBER(8,2); donation_bal NUMBER(8,2); pledge_amt NUMBER(8,2); BEGIN SELECT pledge_amt, pledge_date, pay_months, INTO pledge_amt, start_date, num_of_pmt FROM DD_PLEDGE WHERE IDPLEDGE = &IDPLEDGE; mth_pmt_amt:=(pledge_amt/num_of_pmt); due_date:=start_date; donation_bal:=(pledge_amt-mth_pmt_amt); pmt_num:=0; FOR i IN 1..num_of_pmt LOOP pmt_num:=pmt_num +1; due_date:=add_month(due_date,1); dbms_output.put_line('Payment Number: ' || pmt_num || ' Due Date: ' || due_date || ' Payment Amount: $' || mth_pmt_amt || ' Balance: $' || to_char(donation_bal,'$9999.99')); donation_bal:=donation_bal - mth_pmt_amt; EXIT WHEN donation_bal <0; END LOOP; END;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2012 Administration

Authors: Adam Jorgensen, Steven Wort

1st Edition

1118106881, 9781118106884

More Books

Students also viewed these Databases questions

Question

How could assessment be used in an employee development program?

Answered: 1 week ago