We help IT Professionals succeed at work.
Get Started

Oracle -- Multiple SELECT statement ?

finance_teacher
on
810 Views
Last Modified: 2013-12-18
The below SELECT displays the EMPLOYEE's MANAGER.

  SELECT SUP_POS_CODE FROM COMPANY_POSITION
  where POS_CODE = '101/3802'

What SELECT or PL/SQL will allow me to
enter '101/3802' and get the below, indented ?

    100/1000 PRESIDENT
      101/3005 MANAGER
       101/3802 EMPLOYEE
        ........ there will be more layers
                 depending on who is picked
-----------------------------------------------------------------------------
  CREATE TABLE "COMPANY_POSITION_STRUCTURE_TAB"
   (      "COMPANY_ID" VARCHAR2(20 CHAR),
      "POS_CODE" VARCHAR2(10 CHAR),
      "VALID_TO" DATE,
      "VALID_FROM" DATE,
      "SUP_POS_CODE" VARCHAR2(10 CHAR),
      "ALTKEY" VARCHAR2(100 CHAR),
      "ROWVERSION" NUMBER DEFAULT 1
   ) ;

Insert into "company_position_structure_tab"

(COMPANY_ID,POS_CODE,VALID_TO,VALID_FROM,SUP_POS_CODE,ALTKEY,ROWVERSION) values

('10','100/1000',to_timestamp('12/31/9999','MM/DD/YYYY HH.MI.SSXFF AM'),to_timestamp('01/01/0001','MM/DD/YYYY

HH.MI.SSXFF AM'),'*','10^100/1000^99991231',1);
Insert into "company_position_structure_tab"

(COMPANY_ID,POS_CODE,VALID_TO,VALID_FROM,SUP_POS_CODE,ALTKEY,ROWVERSION) values

('10','101/3005',to_timestamp('12/31/9999','MM/DD/YYYY HH.MI.SSXFF AM'),to_timestamp('03/11/2011','MM/DD/YYYY

HH.MI.SSXFF AM'),'100/1000','10^101/3005^99991231',1);
Insert into "company_position_structure_tab"

(COMPANY_ID,POS_CODE,VALID_TO,VALID_FROM,SUP_POS_CODE,ALTKEY,ROWVERSION) values

('10','101/3005',to_timestamp('03/10/2011','MM/DD/YYYY HH.MI.SSXFF AM'),to_timestamp('01/01/0001','MM/DD/YYYY

HH.MI.SSXFF AM'),'196/1001','10^101/3005^20110310',2);
INSERT INTO "company_position_structure_tab"

(COMPANY_ID,POS_CODE,VALID_TO,VALID_FROM,SUP_POS_CODE,ALTKEY,ROWVERSION) VALUES

('10','101/3802',TO_TIMESTAMP('12/31/9999','MM/DD/YYYY HH.MI.SSXFF AM'),TO_TIMESTAMP('01/01/0001','MM/DD/YYYY

HH.MI.SSXFF AM'),'101/3005','10^101/3802^99991231',1);
Comment
Watch Question
Database Developer & Administrator
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2012
Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE