Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Selecting the earliest admission

Selecting the earliest admission

From: <simpsonj_at_imsweb.com>
Date: 22 Feb 2006 15:09:00 -0800
Message-ID: <1140649740.542846.318630@o13g2000cwo.googlegroups.com>


Hi everyone. I currently have a procedure that takes the parameters, v_case_id and v_fac_id, finds the earliest admission date and returns the admission_id of the earliest admission date. Here is the SQL from this procedure:

SELECT admission_id

    FROM

          (SELECT admission_id
                  FROM admission a1
                         JOIN case c1 ON ca.case_id = a1.case_id
                    WHERE
                        c1.case_id = v_case_id
                        AND a1.fac_id = v_fac_id
                    ORDER BY
                        a1.date_of_disch_yyyy,
                        a1.date_of_disch_mm,
                        a1.date_of_disch_dd)
    WHERE
                rownum = 1)

This procedure works fine, but my problem lies in that I want to use the funtionality of this procedure in the where clause of another in order to select the admission with the earliest discharge for each person. However, I am not able to use the actual procedure. Ex.

SELECT

By putting the logic from the procedure at the beginning of the posting into the where clause and replacing the parameters v_case_id and v_fac_id, with a.admission_id and c.case_id, I get an error because the inner select is too deeply nested to recognize these values. Does anyone have an idea of how I can get around this problem? Received on Wed Feb 22 2006 - 17:09:00 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US