Subject Cursor not Executing Properly
Author Vishal Tiwari
Hi All, 

I have created the below cursor on Firbird DB (version 2.5). The update statement in below cursor is not updating value.
 
execute block
as                                  
declare contractno CHAR(20);
declare cur_list_of_contracts cursor for (Select CU.CONTRACTNO From CLASSIC_UPGRADE CU, CONTRACT C where C.CONTRACTNO = CU.CONTRACTNO AND C.CONTRACTSTATUS = 'A' AND CU.INSERTDATE > '09/01/2016' AND CU.INSERTDATE < '09/10/2016' AND (CU.status = 'authorized' or CU.status = 'Authorized') AND C.CONVERT2YRDATE IS NULL  );
 
begin
open cur_list_of_contracts;
  while (ROW_COUNT > 0) do
  begin
    fetch cur_list_of_contracts into contractno;
    UPDATE CONTRACT C
    SET CONVERT2YRDATE = (SELECT CU.INSERTDATE From CLASSIC_UPGRADE CU where CU.CONTRACTNO = :contractno)
    where C.CONTRACTNO = :contractno;
 
    if (ROW_COUNT = 0) then leave;
    suspend;
  end
  close cur_list_of_contracts;
end;
 
   
The block is getting executed without any errors.

But, the output is not as expected. The records in the table are not getting updated.


With Best Regards.

Vishal