SQL Problems Requiring Cursors - Example: Insert Rows Based On A Count in The Table Itself - Solution in Cursor Form

Solution in Cursor Form

Generating the target table with a cursor is fairly simple.

declare cursor c is select * from marbles_seed; begin for r in c loop for i in 1..r.quantity loop insert into marbles values ( r.texture, r.appearance, r.shape, r.color_actual ); end loop; end loop; end;

Read more about this topic:  SQL Problems Requiring Cursors, Example: Insert Rows Based On A Count in The Table Itself

Famous quotes containing the words form and/or solution:

    The form of act or thought mattered nothing. The hymns of David, the plays of Shakespeare, the metaphysics of Descartes, the crimes of Borgia, the virtues of Antonine, the atheism of yesterday and the materialism of to-day, were all emanation of divine thought, doing their appointed work. It was the duty of the church to deal with them all, not as though they existed through a power hostile to the deity, but as instruments of the deity to work out his unrevealed ends.
    Henry Brooks Adams (1838–1918)

    There’s one solution that ends all life’s problems.
    Chinese proverb.