fetching rows one by one and inserting rows in another table to cursor

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sumantabhowmick
    New Member
    • May 2014
    • 1

    fetching rows one by one and inserting rows in another table to cursor

    Hi,

    I have two tables. The first table T1 contains columns StartChequeNo, AccountNo and ChequeBookSize. Values are StartChequeNo - 65551, AccountNo - 2321, ChequeBookSize - 10 like wise there are 100 rows for 100 different accounts. I have to insert the same data in another table T2 irrespective of the ChequeBookSize ie., If the ChequeBookSize is 10 in table T1 then I have to insert rows to T2 table 10 times with different cheques series like:
    TABLE T2:
    StartChequeNo AccountNo
    65551 2321
    65552 2321
    65553 2321...
    and the same loop will goes till the nof of times equal to the cheque book size i.e., is 10 times and also the cheque book size are different for every account.

    Any help toward this is appreciated that how to make this possible in form of cursor in Oracle.
  • Luuk
    Recognized Expert Top Contributor
    • Mar 2012
    • 1043

    #2
    Code:
    INSERT INTO T2 (ChequeNo, AccountNo) 
    SELECT StartChequeNo+ROWNUM-1,  AccountNo  FROM T1;

    Comment

    Working...