DECLARE @list_item_santunan TABLE ( kode_item VARCHAR(10),
                                    model SMALLINT,
                                    nama_santunan VARCHAR(250),
                                    kode_admedika VARCHAR(5),
                                    kode_admedika_new VARCHAR(2),
                                    jml_prs_pake INT)
INSERT INTO @list_item_santunan
        (kode_item,
         model,
         nama_santunan,
         kode_admedika,
         kode_admedika_new,
         jml_prs_pake)
SELECT
	Kode_Item,          -- kode_item - varchar(10)
	Model,              -- model - smallint
	Nama_Santunan,      -- nama_santunan - varchar(250)
	Kode_Admedika,      -- kode_admedika - varchar(5)
	Kode_Admedika_new,  -- kode_admedika_new - varchar(2)
	0                   -- jml_prs_pake - int
FROM
	dbo.Item_Santunan

DECLARE @no_proposal VARCHAR(9)

DECLARE list_cursor CURSOR FAST_FORWARD FOR 
SELECT
	No_Proposal
FROM
	dbo.Polis_Asuransi AS pa
WHERE
  pa.Tgl_Mulai >= '2014-01-01'
  AND pa.Tgl_Mulai <= GETDATE()
  AND Status NOT IN ('G')

OPEN list_cursor  
FETCH NEXT FROM list_cursor INTO @no_proposal  

WHILE @@FETCH_STATUS = 0  
BEGIN  

  --start: sub cursor--
  DECLARE @kode_item VARCHAR(10)
  DECLARE list_cursor_2 CURSOR FAST_FORWARD FOR 
  SELECT
  	[is].Kode_Item--,
  	--[is].Model,
  	--[is].Nama_Santunan,
  	--[is].Kode_Admedika,
  	--[is].Kode_Admedika_new
  FROM
  	dbo.Produk_Polis AS pp INNER JOIN
  	dbo.Item_Santunan_Polis AS isp ON pp.Id_Produk = isp.Id_Produk INNER JOIN
  	dbo.Item_Santunan AS [is] ON isp.Kode_Santunan = [is].Kode_Item
  WHERE
    pp.No_Proposal = @no_proposal
  
  OPEN list_cursor_2  
  FETCH NEXT FROM list_cursor_2 INTO @kode_item  
  
  WHILE @@FETCH_STATUS = 0  
  BEGIN 
    
    UPDATE 
      @list_item_santunan
    SET
      jml_prs_pake = jml_prs_pake + 1
    WHERE
      kode_item = @kode_item
    
    FETCH NEXT FROM list_cursor_2 INTO @kode_item  
  END  

  CLOSE list_cursor_2  
  DEALLOCATE list_cursor_2 
  --end: sub cursor--

  FETCH NEXT FROM list_cursor INTO @no_proposal  
END  

CLOSE list_cursor  
DEALLOCATE list_cursor 

SELECT
	*
FROM
	@list_item_santunan
