나는 mysql 저장 프로 시저를 재귀 적으로 만들었으며 항상 최대 499 행을 반환했다. 내 저장 프로 시저가 트리 (이진 트리가 아님)에서 이동하고 자식 노드가 있는지 노드를 확인한 다음 잎이 도달 할 때까지 확인합니다.mysql에서 무제한 재귀를 수행하는 방법은 무엇입니까?
난, 난 그냥 견인 점을 요청하는 방법을 나는 비 재귀 방식으로 내 코드를 변환 할 수 있습니다 모른다 : 내가 MySQL의에서 무한 재귀를 만들 수있는 방법
- 을 (MySQL 서버 버전이다 5.5)?
그럴 수 없다면 어떻게 내 코드를 비 재귀 적 방식으로 변경할 수 있습니까?
CREATE PROCEDURE `get_citations`(in _pub_id int(10),in _lvl int,citation_count int) BEGIN DECLARE done INT DEFAULT FALSE; declare p_id,c_count int; declare _counter int default 1; DECLARE cur1 CURSOR FOR SELECT pat_publn_id,cited_count from temp.a_citations where pub_parent=_pub_id ; DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; insert into a_citations (pat_publn_id , publn_nr , publn_kind, publn_auth, publn_date, cited_pat_publn_id, cited_count, pub_lvl, pub_parent) (select p.pat_publn_id,p.publn_nr,p.publn_kind,p.publn_auth,p.publn_date,c.cited_pat_publn_id, (select count(*) as cnt FROM patstat1304.tls212_citation c2 where c2.cited_pat_publn_id=c.pat_publn_id) as cited_count,_lvl as pub_lvl,_pub_id as pub_parent from patstat1304.tls212_citation c,patstat1304.tls211_pat_publn p where c.pat_publn_id=p.pat_publn_id and c.cited_pat_publn_id=_pub_id); commit; OPEN cur1; read_loop: LOOP fetch cur1 into p_id,c_count; IF (c_count !=0) then call get_citations(p_id,_lvl+1,c_count); commit; END if; IF done THEN LEAVE read_loop; END IF; set _counter=_counter+1; if(_counter=citation_count) then LEAVE read_loop; end if; end loop; CLOSE cur1; END