Forum Stats

  • 3,781,442 Users
  • 2,254,520 Discussions
  • 7,879,699 Comments

Discussions

PL/SQL LOOPS

User_4G3I3
User_4G3I3 Member Posts: 9 Green Ribbon

Lets I have two column data

Column one = ID say (101,102,103), Column two = payments say values ($20,$30$,$30 etc)

Each ID/Payment repeats multiple times, a good example is the installment payment of an item you are financing.

So a typical output will be

ID Payment

101 $20

101 $20

101 $20

102 $30

102 $30

103 $20

103 $30

etc

I have used a block of "explicit cursor" to fetch data using a loop. There is an "if statement" after  DBMS_OUTPUT.PUT_LINE before "END LOOP"

the current "IF statement" I have goes like

IF cursor_name%rowcount = 1 then DBMS_OUTPUT...("First month payment"); end if; end loop;

Now, this method displays the if statement block only on the first row which is ID 101 payment $20.

What I want is to display the if statement message for every first occurrence of new ID, just the first payment. So how can I detect every new ID and display the message but only on the first row of the new ID?

Tagged:

Answers