truncate table output
/
-------------------------------------------------------------------------------
-- Implicit Cursors (no cursor definition)
--
-- Use for: INSERT, UPDATE and DELETE
-- Use for: SELECT...INTO, providing the select will only return a single row
-------------------------------------------------------------------------------

DECLARE 
    pay_num payment.payment_num%TYPE;       -- same type as table.column
    vendor  payment.vendor%TYPE;
    description payment.description%TYPE;
    amount  payment.amount%TYPE;
    pay_date    payment.pay_date%TYPE;

    payment_row payment%ROWTYPE;            -- same type as entire table row

    rec_count   integer; 

BEGIN
    SELECT count(*) INTO rec_count from payment;            -- implicit cursor

    FOR i IN  1..rec_count  LOOP
    SELECT payment_num,vendor,description,amount,pay_date   -- implicit cursor
      INTO pay_num,vendor,description,amount,pay_date
      from payment
     where payment_num = i;                 -- Notice only 1 record (at a time)

    INSERT into output                      
        values(pay_num||' '||vendor||' '||description||' $'||amount||' '||pay_date);


    SELECT * INTO payment_row                               -- implicit cursor
      from payment
     where payment_num = i;

    INSERT into output                                      -- implicit cursor
        values(payment_row.payment_num||' '|| ' $'||payment_row.amount);

    END LOOP;
END;
/


select * from output