Input required..need help:recursive procedure & container logic
-
I want to write a procedure 1.find the child of a parent recursively till we do not find any child. 2.Then collect all the child in get in step one and update the value of name of all the child-->second procedure approach: 1. write a procedure to take all the parent as input 2. write a procedure to find child recursively till we do not find any child further e.g 1:parent 1.1 child now consider 1.1 as parent and find child e.g 1.2 recursively call and collect and then update all the child name proc 2: simple procedure with update where id ("child we got previously ") I got the logic but do not know how to call recursively the procedure and hold the values of child any sample code or input is highly appreciated!!! Thanks, Ramina
-
I want to write a procedure 1.find the child of a parent recursively till we do not find any child. 2.Then collect all the child in get in step one and update the value of name of all the child-->second procedure approach: 1. write a procedure to take all the parent as input 2. write a procedure to find child recursively till we do not find any child further e.g 1:parent 1.1 child now consider 1.1 as parent and find child e.g 1.2 recursively call and collect and then update all the child name proc 2: simple procedure with update where id ("child we got previously ") I got the logic but do not know how to call recursively the procedure and hold the values of child any sample code or input is highly appreciated!!! Thanks, Ramina
-
I want to write a procedure 1.find the child of a parent recursively till we do not find any child. 2.Then collect all the child in get in step one and update the value of name of all the child-->second procedure approach: 1. write a procedure to take all the parent as input 2. write a procedure to find child recursively till we do not find any child further e.g 1:parent 1.1 child now consider 1.1 as parent and find child e.g 1.2 recursively call and collect and then update all the child name proc 2: simple procedure with update where id ("child we got previously ") I got the logic but do not know how to call recursively the procedure and hold the values of child any sample code or input is highly appreciated!!! Thanks, Ramina
Is there some reason for doing this recursively, you should be able to achieve a simple update in one sql statement using an inner join!
Never underestimate the power of human stupidity RAH
-
Is there some reason for doing this recursively, you should be able to achieve a simple update in one sql statement using an inner join!
Never underestimate the power of human stupidity RAH
correct, but as I have mention my inner query is giving me only parent but I want to make use of the result of the inner query again as input till I did not find any child ,so I am using procedure as I have to collect all the parent I get from the inner query and then update the outer query using the inner query result.it is the requirement what I want to achive, e.g update table A set A.a as "xyz" //here I will get t where A.id in ( select A.child_id from A,B,C --I get the child by passing parent as input and again consider the child as parent and find the child where A.id= b.id b.name = x and A.prent_id = ? //few join condtion here ) e.g input 1 result 1.1 input 1.1 result 1.1.1 input 1.1.1 result 1.1.1.1 update A where A.id in ('1.1','1.1.1','1.1.1.1')--here I want to use a container and make use of it Hope you get my intention now ..Thanks for your response.