Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

What to use: Record or Cursor?

$
0
0
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 a monthly payments, display “Monthly - #” (with the # representing the number of months for payment)
• The list should be sorted to display all lump sum pledges first.

here is the table struc.

CREATE TABLE DD_Pledge (
idPledge number(5),
idDonor number(4),
Pledgedate DATE,
Pledgeamt number(8,2),
idProj number(5),
idStatus number(2),
Writeoff number(8,2),
paymonths number(3),
Campaign number(4),
Firstpledge char(1),
CONSTRAINT pledge_id_pk PRIMARY KEY(idPledge),
CONSTRAINT pledge_idDonor_fk FOREIGN KEY (idDonor)
REFERENCES dd_donor (idDonor),
CONSTRAINT pledge_idProj_fk FOREIGN KEY (idProj)
REFERENCES dd_project (idProj),
CONSTRAINT pledge_idStatus_fk FOREIGN KEY (idStatus)
REFERENCES dd_status (idStatus));

I tried to use record but seems that record is not going to work as it gives me error when the specified month has more then one pledge. Is there a way to do it using record (coz this is an assignment we take it after we covered the record)

Maybe cursor will be a good choice but due to the point mentioned earlier I'd like to know what are the ways to solve this one.

Viewing all articles
Browse latest Browse all 13329

Trending Articles