0

I inserted record into a table with the help of Cursor and loop after closing cursor i wrote update statement to update some record which inserted by cursor so reords not updating. but i ran query outside then records updating

my try is drop procedure if exists kpsf_inopdormantac;

create procedure kpsf_inopdormantac(inp_branchcode varchar(6), inp_date date)

begin  declare c_branchcode varchar(6);
declare c_accounttype varchar(4); 
declare c_accountsubtype varchar(6); 
declare c_accountno varchar(12);
declare c_lasttxndate date;
declare c_inopdate date;
declare c_temp varchar(25);

declare c1 cursor for SELECT
branchcode, accounttype, accountsubtype, accountno, lasttxndate, inoperativedate FROM accountmaster WHERE branchcode = inp_branchcode AND accounttype in ('10','11') AND accountstatus!='C' AND lasttxndate < ( SELECT date_add(inp_date,interval -24 month));

truncate table inopdormantac;
commit;
open c1;
loop1:loop fetch c1 into c_branchcode, c_accounttype, c_accountsubtype, c_accountno, c_lasttxndate, c_inopdate;

INSERT into inopdormantac (branchcode, accounttype, accountsubtype, accountno, acstatus, lasttxndate, inopdate)
VALUES 
(c_branchcode, c_accounttype, c_accountsubtype, c_accountno, 'InOperative', c_lasttxndate, c_inopdate);

end loop loop1;
close c1;
set c_temp='InActive';

update inopdormantac SET acstatus = c_temp WHERE lasttxndate < ( SELECT
date_add('2015-10-06',interval -120 month));
end;

plz help me

Samir Selia
  • 7,007
  • 2
  • 11
  • 30
Ritesh Fondke
  • 122
  • 1
  • 11

1 Answers1

0

Potentially you might be running DB instance in safe-updates mode. Please see another question which have been already answered: MySQL error code: 1175 during UPDATE in MySQL Workbench

Community
  • 1
  • 1
llesiuk
  • 21
  • 5