1

I have the following table

CREATE TABLE regions
(
        PARENT_NAME     VARCHAR2(30),
        CHILD_NAME      VARCHAR2(30)
);

I need to perform recursion using cursors in Pl/SQL like that accepts a region name (CHILD_NAME) from the user input and display all its parent regions. Any suggestions?.

2
  • Are you sure you need recursion for this? Commented Oct 4, 2012 at 4:34
  • @zander Dear pseudo code is going to be like this v_child_name v_partent_name select parent_name into v_partent_name from region where child_name = v_child_name; On the very next iteration v_parent_name should become child till the output is not null. Commented Oct 4, 2012 at 4:45

1 Answer 1

7
select parent_name
from regions
start with child_name = :CHILD_NAME
connect by prior parent_name = child_name;
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the support. Can you provide me the pl/sql statement for that....
Are you asking how to incorporate a SQL statement into PL/SQL? Read the docs, they're an excellent introduction to PL/SQL - e.g. docs.oracle.com/cd/E11882_01/appdev.112/e25519/…

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.