Re: Display all the records from table using cursor
Posted by:
kaji Pasa
Date: September 25, 2017 12:56PM
The below cursor i have made.
I could not find why the update code is not working which is in comment in the below code
************************************************************************************
drop procedure build_title_list2;
DELIMITER $$
CREATE PROCEDURE build_title_list2 ( )
BEGIN
declare no_more_rows boolean default false;
DECLARE v_title_sci varchar(1000) DEFAULT "";
DECLARE v_st varchar(1000) DEFAULT "";
Declare v_issn1 varchar(100);
declare v_issn2 varchar(100);
declare v_title varchar(1000);
declare v_issn varchar(100);
declare v_eissn varchar(100);
declare v_databas varchar(1000);
declare v_cc varchar(1000);
DECLARE v_b_title_sci varchar(1000) DEFAULT "";
DECLARE v_b_st varchar(1000) DEFAULT "";
Declare v_b_issn1 varchar(100);
declare v_b_issn2 varchar(100);
declare v_b_title varchar(1000);
declare v_b_issn varchar(100);
declare v_b_eissn varchar(100);
declare v_b_databas varchar(1000);
declare v_b_cc varchar(1000);
DEClARE master_cursor CURSOR FOR
SELECT StandardTitle,Title_sci,issn1,issn2,title,issn,eissn,databas,cc FROM master_data;
Declare base_cursor cursor for
-- select * from base_report_gt_zero
select standardtitle, title_sci,issn1,issn2,title,issn,eissn,databas,cc from base_report_gt_zero
where standardtitle = v_st and title_sci=v_title_sci and issn1=v_issn1 and issn2=v_issn2 and title=v_title
and issn=v_issn and eissn=v_eissn and databas=v_databas;
DECLARE CONTINUE HANDLER
FOR NOT FOUND SET no_more_rows := true;
OPEN master_cursor;
loop1: LOOP
FETCH master_cursor INTO v_st,v_title_sci,v_issn1,v_issn2,v_title,v_issn,v_eissn,v_databas,v_cc;
if no_more_rows then
close master_cursor;
LEAVE loop1;
END IF;
open base_cursor;
loop2:LOOP
FETCH base_cursor INTO v_b_st,v_b_title_sci,v_b_issn1,v_b_issn2,v_b_title,v_b_issn,v_b_eissn,v_b_databas,v_b_cc;
-- update base_report_gt_zero set cc=v_cc ;
if no_more_rows then
set no_more_rows := false;
close base_cursor;
leave Loop2;
end if ;
select v_cc ;
select v_b_st,v_b_title_sci,v_b_issn1,v_b_issn2,v_b_title,v_b_issn,v_b_eissn,v_b_databas,v_b_cc;
end loop loop2;
end loop loop1;
end$$
DELIMITER ;
Subject
Views
Written By
Posted
4059
September 22, 2017 06:21PM
884
September 22, 2017 07:46PM
920
September 22, 2017 10:11PM
801
September 25, 2017 09:07AM
789
September 25, 2017 11:17AM
745
September 25, 2017 11:15AM
851
September 25, 2017 12:49PM
754
September 25, 2017 01:18PM
660
September 25, 2017 01:36PM
654
September 25, 2017 02:00PM
664
September 25, 2017 03:51PM
764
September 25, 2017 06:24PM
679
September 26, 2017 01:34PM
713
September 26, 2017 01:56PM
629
September 26, 2017 02:22PM
745
September 26, 2017 03:35PM
687
September 27, 2017 10:28AM
774
September 27, 2017 11:39AM
733
September 26, 2017 12:43PM
715
September 26, 2017 01:27PM
675
September 26, 2017 01:44PM
778
September 25, 2017 01:46PM
Re: Display all the records from table using cursor
799
September 25, 2017 12:56PM