I have a requirement like below . I have a table with 2 columns, (contract_id,line_num)
create table tx (contract_id number,line_num number);
I have data like
contract_id  ||   line_num
-----------      ---------
 1           ||      1
 1           ||      null
 1           ||      null
 2           ||       1
 2           ||      null
 2           ||      null
 3           ||      1
 3           ||      null
I have to write a plsql block , first I have to get the max(line_num) for each contract_id, and then update the next sequence number for each contract_id where ever there is null in line_num column for each contract_id using cursor for loop.   
I should get like below
contract_id    ||     line_num
-----------          ---------
   1           ||      1
   1           ||      2
   1           ||      3
   2           ||      1
   2           ||      2
   2           ||      3
   3           ||      1
   3           ||      2 
can u pls help me with this...
DECLARE
    var1   NUMBER := 0;
BEGIN
    SELECT MAX (gocpd.column46)
      INTO var1
      FROM gecm_okc_con_part_details gocpd, okc_rep_contracts_all orca
     WHERE     gocpd.contract_id = orca.contract_id
           AND orca.attribute12 = 'GE-Power' --AND GOCPD.COLUMN46 = NULL AND GOCPD.CONTRACT_ID = 525215; END
                                            ;
    BEGIN
        UPDATE GECM_OKC_CON_PART_DETAILS GOCPD
           SET GOCPD.COLUMN46 = var1 + 1
          FROM okc_rep_contracts_all orca
         WHERE     gocpd.contract_id = orca.contract_id
               AND orca.attribute12 = 'GE-Power'
               AND gocpd.column46 = NULL
               AND gocpd.contract_id = 525215;
        COMMIT;
    END;
END;
 
     
    