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 solution and/or form:

    The truth of the thoughts that are here set forth seems to me unassailable and definitive. I therefore believe myself to have found, on all essential points, the final solution of the problems. And if I am not mistaken in this belief, then the second thing in which the value of this work consists is that it shows how little is achieved when these problems are solved.
    Ludwig Wittgenstein (1889–1951)

    The man who is admired for the ingenuity of his larceny is almost always rediscovering some earlier form of fraud. The basic forms are all known, have all been practicised. The manners of capitalism improve. The morals may not.
    John Kenneth Galbraith (b. 1908)