Change of shape joining multi tables SQL...

I need to be able to join the tables in the detail section of my master-detail form. Since I have more than three paintings to join, I think that APEX needs to use "ROWID" to track the value of the key of the primary table. When I try substitute basic sql generated for the report to my own joined table I get an error return "IMPOSSIBLE of ANALYSER. If I remove "ROWID" in the statement, then fine. Here's the statement from the apex generated:

Select
"ROWID",.
"PO_ID."
"PO_DET_ID,"
"CHANGE_ORDER,"
'START_DATE ',.
'END_DATE ',.
"PO_DET_AMT,"
"SCOPE."
"PO_STATUS,"
"MRS."
of ' #OWNER # '. " PO_DETAILS ".
where "PO_ID" =: P240_PO_ID

However, I need for the statement as follows:

Select "ROWID",.
po_details.po_id,
po_details.po_det_id,
po_details.change_order,
po_details.start_date,
po_details.end_date,
po_details.po_det_amt,
po_details. Scope,
po_details.po_status,
po_details. WBS
of PO_DETAILS, IN., WBS, PROJECT
where po_details.po_id = po.po_id
and po.po_number = wbs.po_number_id
and po_details.wbs = wbs.wbs_number_id
and substr (wbs.wbs_number_id, 1, 6) = project.wbs_sequence
and project.project_number = nvl(:F101_FPC_NUMBER,project.project_number)
and po_details.po_id =: P240_PO_ID

Then, I get the following ORACLE error:

•Query cannot be parsed in the generator. If you believe that your query is syntactically correct, check the generic "columns" box below the source of the region without analysis. ORA-00918: column ambiguously defined

I'm guessing that the column "defined ambiguous ' is ROWID.

SELECT the query aspect works fine if I remove ROWID, but I then cannot update the table when the user needs to change the data. I get an exception defined by the user.

I am new to APEX, so I do not know there are certain aspects that I'm missing.
Any tips?

There is no way to use a join of multiple tables in the APEX?

Of course you can. Have you tried again (with the help of PO_DETAILS ROWID in the select statement)?

I tried with a form on EMP and then modified the query to:

select
e."ROWID",
e."EMPNO",
e."ENAME",
e."JOB"
from "#OWNER#"."EMP" e, dept d
where e.deptno = d.deptno
and d.deptno = :P14_DEPTNO

IMHO, it's simply more transparent if you use a view as the source. You select a view, and you update the same point of view.

Published by: InoL on May 14, 2013 13:49

Tags: Database

Similar Questions

  • SELECT - INNER JOIN / multi-table question

    I have a few pages where I can:
    register a new user
    Open as this user which brings me to a home page. from there I can go to 'my page' users where I can see their fine of the initial registry data. I have a link here where I can go to add to their additional profile data that I didn't want to bore in the original registration.

    It perfect all worked with the original test data, I've created in the database.

    After that I added the additional tables needed to feed the profile further I ran into trouble. I could create a new user, see in the database is fine. I see them on the homepage with their information through the Recordset. However when I'd go to their 'my page' none of their information would be fill and go to extra profile update page haven't fired a no records found message.

    Finally, I realized that the reason for this is because the SELECT statement is waiting for the other tables to fill. I filled in the missing data and the query to work. So... Now that I know what is causing the problem I need help to find a solution. Also, I'm still new to find work around me even after 4 days of research and reading messages.

    So when a new user registers, I need to be able to display data from the initial registration on the "my page" and get their user_id for profile tables add somehow so that when I go to the add profile page, there is a link.

    I don't know if I need to do something in the database or in my query. It there any sense to anyone? I need to create the user_id on other tables during registration of origin occurs? If so, how would I go all this?

    Thanks in advance. My INNER JOIN is attached in case it helps.

    I have a few pages where I can:
    register a new user
    Open as this user which brings me to a home page. from there I can go to 'my page' users where I can see their fine of the initial registry data. I have a link here where I can go to add to their additional profile data that I didn't want to bore in the original registration.

    It perfect all worked with the original test data, I've created in the database.

    After that I added the additional tables needed to feed the profile further I ran into trouble. I could create a new user, see in the database is fine. I see them on the homepage with their information through the Recordset. However when I'd go to their 'my page' none of their information would be fill and go to extra profile update page haven't fired a no records found message.

    Finally, I realized that the reason for this is because the SELECT statement is waiting for the other tables to fill. I filled in the missing data and the query to work. So... Now that I know what is causing the problem I need help to find a solution. Also, I'm still new to find work around me even after 4 days of research and reading messages.

    So when a new user registers, I need to be able to display data from the initial registration on the "my page" and get their user_id for profile tables add somehow so that when I go to the add profile page, there is a link.

    I don't know if I need to do something in the database or in my query. It there any sense to anyone? I need to create the user_id on other tables during registration of origin occurs? If so, how would I go all this?

    Thanks in advance. My INNER JOIN is attached in case it helps.

  • SQL +-PROBLEM OF QUERY IN MULTI TABLE

    HAI ALL,

    ANY SUGGESTION PLEASE?

    SUP: SQL +-PROBLEM OF QUERY IN MULTI TABLE


    SQL + QUERY DATA:
    -----------
    SELECT PATIENT_NUM, PATIENT_NAME, HMTLY_TEST_NAME, HMTLY_RBC_VALUE,

    HMTLY_RBC_NORMAL_VALUE, DLC_TEST_NAME, DLC_POLYMORPHS_VALUE,

    PATIENTS_MASTER1 DLC_POLYMORPHS_NORMAL_VALUE, HAEMATOLOGY1,

    DIFFERENTIAL_LEUCOCYTE_COUNT1
    WHERE PATIENT_NUM = HMTLY_PATIENT_NUM AND PATIENT_NUM = DLC_PATIENT_NUM AND PATIENT_NUM

    = & PATIENT_NUM;
    -----------
    RESULT:

    & PATIENT_NUM = 1
    no selected line
    ---------
    & PATIENT_NUM = 2
    no selected line
    ------------
    & PATIENT_NUM = 3
    PATIENT_NUM 3

    PATIENT_NAME KKKK

    HMTLY_TEST_NAME HEMATOLOGY

    HMTLY_RBC_VALUE 4
    4.6 - 6.0 HMTLY_RBC_NORMAL

    DLC_TEST_NAME LEUKOCYTE COUNT PREMIUM

    DLC_POLYMORPHS_VALUE 60

    DLC_POLYMORPHS_NORMAL_VALUE 40-65

    -------------
    -------------

    REAL WILL BE:

    & PATIENT_NUM = 1

    PATIENT_NUM 1

    PATIENT_NAME BBBB

    HMTLY_TEST_NAME HEMATOLOGY

    HMTLY_RBC_VALUE 5
    4.6 - 6.0 HMTLY_RBC_NORMAL

    -----------

    & PATIENT_NUM = 2

    PATIENT_NUM 2

    PATIENT_NAME GEORGE

    DLC_TEST_NAME LEUKOCYTE COUNT PREMIUM

    DLC_POLYMORPHS_VALUE 42

    DLC_POLYMORPHS_NORMAL_VALUE 40-65
    ---------------
    & PATIENT_NUM = 3
    PATIENT_NUM 3

    PATIENT_NAME KKKK

    HMTLY_TEST_NAME HEMATOLOGY

    HMTLY_RBC_VALUE 4
    4.6 - 6.0 HMTLY_RBC_NORMAL

    DLC_TEST_NAME LEUKOCYTE COUNT PREMIUM

    DLC_POLYMORPHS_VALUE 60

    DLC_POLYMORPHS_NORMAL_VALUE 40-65
    ----------------------------

    4 TABLES OF LABORATORY CLINIC FOR DATA ENTRY AND GET REPORT ONLY FOR THE TESTS CARRIED OUT FOR PARTICULAR

    PATIENT.

    TABLE1:PATIENTS_MASTER1
    COLUMNS: PATIENT_NUM, PATIENT_NAME,

    VALUES:
    PATIENT_NUM
    1
    2
    3
    4
    PATIENT_NAME
    BENAMER
    GIROT
    KKKK
    PPPP
    ---------------
    TABLE2:TESTS_MASTER1
    COLUMNS: TEST_NUM, TEST_NAME

    VALUES:
    TEST_NUM
    1
    2
    TEST_NAME
    HEMATOLOGY
    DIFFERENTIAL LEUKOCYTE COUNT
    -------------

    TABLE3:HAEMATOLOGY1
    COLUMNS:
    HMTLY_NUM, HMTLY_PATIENT_NUM, HMTLY_TEST_NAME, HMTLY_RBC_VALUE, HMTLY_RBC_NORMAL_VALUE

    VALUES:
    HMTLY_NUM
    1
    2
    HMTLY_PATIENT_NUM
    1
    3
    MTLY_TEST_NAME
    HEMATOLOGY
    HEMATOLOGY
    HMTLY_RBC_VALUE
    5
    4
    HMTLY_RBC_NORMAL_VALUE
    4.6 - 6.0
    4.6 - 6.0
    ------------

    TABLE4:DIFFERENTIAL_LEUCOCYTE_COUNT1
    COLUMNS: DLC_NUM, DLC_PATIENT_NUM, DLC_TEST_NAME, DLC_POLYMORPHS_VALUE, DLC_POLYMORPHS_

    NORMAL_VALUE,

    VALUES:
    DLC_NUM
    1
    2
    DLC_PATIENT_NUM
    2
    3
    DLC_TEST_NAME
    DIFFERENTIAL LEUKOCYTE COUNT
    DIFFERENTIAL LEUKOCYTE COUNT
    DLC_POLYMORPHS_VALUE
    42
    60
    DLC_POLYMORPHS_NORMAL_VALUE
    40-65
    40-65
    -----------------


    Thank you
    RCS
    E-mail:[email protected]
    --------

    I think you want an OUTER JOIN

    SELECT PATIENT_NUM, PATIENT_NAME, HMTLY_TEST_NAME, HMTLY_RBC_VALUE,
     HMTLY_RBC_NORMAL_VALUE, DLC_TEST_NAME, DLC_POLYMORPHS_VALUE,
     DLC_POLYMORPHS_NORMAL_VALUE
    FROM PATIENTS_MASTER1, HAEMATOLOGY1,  DIFFERENTIAL_LEUCOCYTE_COUNT1
    WHERE PATIENT_NUM = HMTLY_PATIENT_NUM (+)
    AND PATIENT_NUM = DLC_PATIENT_NUM (+)
    AND PATIENT_NUM = &PATIENT_NUM;
    

    Published by: shoblock on November 5, 2008 12:17
    the outer join brands became stupid emoticons or something. try hard

  • SQL database need to change single user for multi user mode.

    Hello

    I have a name of database sql as kumar.

    I changed the mode to multi user in single user mode, but unfortunately I forgot to change the mode.

    So, now I can't able to connect at the base of his error showing as already access that a single user can connect at the same time.

    Please help me solve this problem.

    Concerning

    Kumar

    Hello

    The problem has been resolved.

    Ground:

    We restarted the database and then changed the single-user mode to multi user mode.

    We now have access to the database.

    Thank you

    Kumar

  • SQL: JOIN two table also corresponding column NULL how?

    Hello

    I'm trying to join two tables which works fine,
    But if there are NULL values, then, JOIN does not.
    I have two tables TEMP_DD AND TEMP_EE, in which two line
    is the column: allocation A_ID,.
    IE: 112 and NULL and I want both my sql output, but how?

    I tried under sql as it returns only a single line of 112 and does not return a null row which is a football game.


    SELECT * FROM TEMP_DD
    JOIN TEMP_EE
    ON (TEMP_DD.A_ID = TEMP_EE.A_ID);
    How to remedy this situation?

    create table TEMP_DD
    (
      A_ID VARCHAR2(3),
      B_ID VARCHAR2(4),
      C_ID VARCHAR2(10)
    );
    
    create table TEMP_EE
    (
      A_ID VARCHAR2(3),
      B_ID VARCHAR2(4),
      C_ID VARCHAR2(10)
    );
    
    insert into TEMP_DD (A_ID, B_ID, C_ID)
    values ('112', '1123', '12345678');
    insert into TEMP_DD (A_ID, B_ID, C_ID)
    values (NULL, '1123', '12345678');
    insert into TEMP_DD (A_ID, B_ID, C_ID)
    values ('212', '1123', '12345678');
    
    
    insert into TEMP_EE (A_ID, B_ID, C_ID)
    values ('112', '1123', '12345678');
    insert into TEMP_EE (A_ID, B_ID, C_ID)
    values (NULL, '1123', '12345678');
    insert into TEMP_EE (A_ID, B_ID, C_ID)
    values ('312', '1123', '12345678');
    OUTPUT
    ---------

    "112', ' 1123," "12345678".
    (NULL, ' 1123","12345678 ".

    Hello

    Wrap both sides in an NVL IE. NVL (col1, 'X'), WHERE = NVL(col2,'X').

    See you soon

    Ben

  • Outer join complete Multi Table

    What is the syntax to make a full outer join on three tables. All the examples I can find use using the clause, but in my case, the column names are not the same in the three tables

    Hello

    Use IT instead of USE.

    Assuming that all the 3 tables will have a common value in a column (whatever it is called):

    ...
    FROM           table_x  x
    FULL OUTER JOIN      table_y  y     ON     y.idy     = x.idx
    FULL OUTER JOIN      table_z  z     ON     z.idz     = COALESCE (x.idx, y.idy)
    

    When comes the time to join table_z, you won't know which of the previous tables match, so you must use COALESCE to try them all.

    If you need to join several tables in this way, the expression of COALESCE for the nth table will have (n - 1) arguments.

  • Joins of tables in the inventory

    Hi all

    Can you please give me the join conditions (request format as where to use an outer join or internal)?

    mtl_material_transactions,

    mtl_system_items_b,

    mtl_parameters

    mtl_item_locations,

    mtl_serial_numbers,

    mtl_lot_numbers

    Here's the sql code.

    We do not have the serial controlled items so I have all the data to validate this sql.

    You need to add a large number of columns in the place where clause change conditions.

    each table has some kind of column field or flag status.

    You can figure that out based on the configuration of your company.

    ======

    Select * from

    mtl_material_transactions mmt,

    MSI mtl_system_items_b,

    mtl_parameters mp,

    mil mtl_item_locations

    mtl_serial_numbers msn,

    mtl_lot_numbers CHF million

    where

    MMT.inventory_item_id = msi.inventory_item_id

    and

    MMT.organization_id = msi.organization_id

    and

    MMT.organization_id = mp.organization_id

    and

    -Outer join MIL incase you don't have parameters of Articles Locators

    MMT.inventory_item_id = mil.inventory_item_Id

    and

    MMT.organization_id = mil.organization_id

    and

    -an outer join on MSN snack items are not control series

    MMT.inventory_item_id = msn.inventory_item_id

    and

    MMT.organization_id = msn.current_organization_id

    and

    -an outer join on mln point snack is not the outer join

    MMT.inventory_item_id = mln.inventory_item_id

    and

    MMT.organization_id = mln.organization_id

    -settings

    and msi.segment1 = «& itemnumber»

    and mmt.organization_id = &org_id;

    =====================

    NOTE: not all run great sql open, it will never be over. Having so many outer joins will not use the index unless you spend in the settings I have used at least.

    all the best.

  • BAD RESULTS WITH OUTER JOINS AND TABLES WITH A CHECK CONSTRAINT

    HII All,
    Could any such a me when we encounter this bug? Please help me with a simple example so that I can search for them in my PB.


    Bug:-8447623

    Bug / / Desc: BAD RESULTS WITH OUTER JOINS AND TABLES WITH a CHECK CONSTRAINT


    I ran the outer joins with check queries constraint 11G 11.1.0.7.0 and 10 g 2, but the result is the same. Need to know the scenario where I will face this bug of your experts and people who have already experienced this bug.


    Version: -.
    SQL> select * from v$version;
    
    BANNER
    --------------------------------------------------------------------------------
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    PL/SQL Release 11.1.0.7.0 - Production
    CORE    11.1.0.7.0      Production
    TNS for Solaris: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - Production

    Why do you not use the description of the bug test case in Metalink (we obviously can't post it here because it would violate the copyright of Metalink)? Your test case is not a candidate for the elimination of the join, so he did not have the bug.

    Have you really read the description of the bug in Metalink rather than just looking at the title of the bug? The bug itself is quite clear that a query plan that involves the elimination of the join is a necessary condition. The title of bug nothing will never tell the whole story.

    If you try to work through a few tens of thousands of bugs in 11.1.0.7, of which many are not published, trying to determine whether your application would be affected by the bug? Wouldn't be order of magnitude easier to upgrade the application to 11.1.0.7 in a test environment and test the application to see what, if anything, breaks? Understand that the vast majority of the problems that people experience during an upgrade are not the result of bugs - they are the result of changes in behaviour documented as changes in query plans. And among those who encounter bugs, a relatively large fraction of the new variety. Even if you have completed the Herculean task of verifying each bug on your code base, which would not significantly easier upgrade. In addition, at the time wherever you actually performed this analysis, Oracle reportedly released 3 or 4 new versions.

    And at this stage would be unwise to consider an upgrade to 11.2?

    Justin

  • Join several Tables versioned

    Hello

    We are working on a data warehousing project and wonder how do to join several tables that each are versioned separately (type SCD 2 with a valid and valid to date).

    Because for example, we get our client from a single source of information (id customer, name, etc.) and the information on the rate of customer from another source.  The sources are different, we have the separate tables for them and each of them gets versioned independently.

    Here's my customer table (with its own valid and valuable to the columns).

    IDName of the customerValid fromValid until the
    1CitiBank1 JANUARY 14JANUARY 1, 15
    1New CitiBank2 JANUARY 15FEBRUARY 1, 15
    1Latest CitiBank2 FEBRUARY 15APRIL 1, 15

    And similarly the Client side ID and rating information.

    IDNoteValid fromValid until the
    1Platinum1 JANUARY 14FEBRUARY 1, 14
    1PremiumFEBRUARY 1, 141ST MARCH 15

    I want to merge the two tables above and present information at a glance.  I have some difficulty to determine validates the valid columns.

    IDName of the customerNoteValid from (Calculated)Valid until the (calculated)
    1CitiBankPlatinum1 JANUARY 14FEBRUARY 1, 14
    1CitiBankPremiumFEBRUARY 1, 14JANUARY 1, 15
    1New CitiBankPremium2 JANUARY 15FEBRUARY 1, 15
    1Latest CitiBankPremium2 FEBRUARY 151ST MARCH 15

    And it's the query I used to get the above result:

    SELECT client. id ,

           customer . name ,

           CRM . level ,

           Greatest (client. vld_fm , crm. vld_fm ),

           Least (client. vld_to , crm. vld_to )

    DE    client client,

           client_rating crm

      client. id = crm. id

           AND ( client. vld_fm <= crm. vld_fm

                 AND client. vld_fm <= crm. vld_to

                 AND client. vld_fm >= crm. vld_fm

                 AND client. vld_fm >= crm. vld_to )

            OR ( client. vld_fm BETWEEN crm. vld_fm AND crm. vld_to )

            OR ( client. vld_to BETWEEN crm. vld_fm AND crm. vld_to );



    The problem is we have several data sources (and each with its own versions) and joins become so very very complex.  Is there a better way to write the query?

    Or maybe a better way to design our tables?

    Thanks for your help.

    Anand

    Hello

    you only need ranges that overlap to join.

    Re: How do to sql query in a loop

    Is a simpler way to test if the x_start to x_stop range comes into conflict with the range of y_start to y_stop

    WHERE     x_start <= y_stop AND     y_start <= x_stop
    

    In other words, two overlapping if and only if everyone will start before the other ends one. If this is not obvious (and it was certainly not clear to me when I heard it), then look at it this way: two ranges are not overlapping if and only if one of them starts after the end of the other.

    Concerning

    Marcus

  • JOIN the question... Join two tables without omitting lines

    I came across a problem that should be an easy fix (I hope), but I'm having a hard time to come up with a solution.

    Basically I have two tables, one with the actual amounts with the budget. I have to write a sql statement select that joins these tables together and includes all of their lines. I was able to join the tables by using JOIN, LEFT JOIN and RIGHT JOIN, but it always fails the lines I need.

    Below, I have examples of my tables (AMOUNT_TABLE and BUDGET_TABLE). For simplicity, I built the examples to show the same values in the first four columns, with the 5th and 6th columns (SUB_ACCOUNT, AMOUNT, BUDGET) as the only values that are different. My actual tables are not quite that simple, but I don't think it was relavent to this issue.

    AMOUNT_TABLE

    FISCAL_YEAR PERIOD ACCT_UNIT ACCOUNT SUB_ACCOUNT AMOUNT

    2013

    111111555555000010020131111115555551000100201311111155555520001002013111111555555300010020131111115555554000100

    BUDGET_TABLE

    FISCAL_YEAR PERIOD ACCT_UNIT ACCOUNT SUB_ACCOUNT BUDGET

    2013

    1111115555553000200201311111155555540002002013111111555555500020020131111115555556000200

    Here's what I hope. Note that SUB_ACCOUNTs 0000, 1000, and 2000 show without budget amounts since there is not a corresponding line in the BUDGET_TABLE. And same for SUB_ACCOUNTs 5000 and 6000, they show budgets with no amount because there is not a corresponding line in the AMOUNT_TABLE.

    (exit)

    FISCAL_YEAR PERIOD ACCT_UNIT ACCOUNT SUB_ACCOUNT AMOUNT BUDGET
    201311111155555500001000
    201311111155555510001000
    201311111155555520001000
    20131111115555553000100200
    20131111115555554000100200
    201311111155555550000200
    201311111155555560000200

    If all goes well, my question is clear. Any help on this would be greatly appreciated. Thanks in advance.

    Use the join ANSI - FULL OUTER JOIN syntax:

    with amount_table like)

    Select fiscal_year 2013, 1 period, 11111 acct_unit, 555555, 0000 sub_account, amount 100 of all the double union

    Select 2013,1,11111,555555,1000,100 from all the double union

    Select 2013,1,11111,555555,2000,100 from all the double union

    Select 2013,1,11111,555555,3000,100 from all the double union

    Select double 2013,1,11111,555555,4000,100

    ),

    budget_table like)

    Select 1 time, 11111 acct_unit, account 555555, sub_account 3000, 2013 fiscal_year, budget of 200 Union double all the

    Select 2013,1,11111,555555,4000,200 from all the double union

    Select 2013,1,11111,555555,5000,200 from all the double union

    Select double 2013,1,11111,555555,6000,200

    )

    Select nvl (a.fiscal_year, b.fiscal_year) fiscal_year,

    period of NVL (a.period, b.period),

    NVL (a.acct_unit, b.acct_unit) acct_unit.

    account of NVL (a.Account, b.Account),

    NVL (a.sub_account, b.sub_account) sub_account.

    Amount NVL(a.amount,0),

    NVL(b.budget,0) budget

    of amount_table one

    full join

    budget_table b

    on)

    a.Fiscal_Year = b.fiscal_year

    and

    a.period = b.period

    and

    a.acct_unit = b.acct_unit

    and

    a.Account = b.account

    and

    a.sub_account = b.sub_account

    )

    /

    FISCAL_YEAR PERIOD ACCT_UNIT ACCOUNT SUB_ACCOUNT AMOUNT BUDGET
    ----------- ---------- ---------- ---------- ----------- ---------- ----------
    2013 1 11111 555555 0 100 0
    2013 1 11111 555555 1000 100 0
    2013 1 11111 555555 2000 100 0
    2013 1 11111 555555 3000 100 200
    2013 1 11111 555555 4000 100 200
    2013 1 11111 555555 6000 0 200
    2013 1 11111 555555 5000 0 200

    7 selected lines.

    SQL >

    SY.

  • date max with multiple joins of tables

    Looking for expert advice on the use of max (date) with multiple joins of tables. Several people have tried (and failed) - HELP Please!

    The goal is to retrieve the most current joined line of NBRJOBS_EFFECTIVE_DATE for each unique NBRJOBS_PIDM. There are several lines by PIDM with various EFFECTIVE_DATEs. The following SQL returns about 1/3 of the files and there are also some multiples.

    The keys are PIDM, POSN and suff

    Select NBRJOBS. NBRJOBS.*,
    NBRBJOB. NBRBJOB.*
    of POSNCTL. Inner join of NBRBJOB NBRBJOB POSNCTL. NBRJOBS NBRJOBS on (NBRBJOB. NBRBJOB_PIDM = NBRJOBS. NBRJOBS_PIDM) and (NBRBJOB. NBRBJOB_POSN = NBRJOBS. NBRJOBS_POSN) and (NBRBJOB. NBRBJOB_SUFF = NBRJOBS. NBRJOBS_SUFF)
    where NBRJOBS. NBRJOBS_SUFF <>'LS '.
    and NBRBJOB. NBRBJOB_CONTRACT_TYPE = 'P '.
    and NBRJOBS. NBRJOBS_EFFECTIVE_DATE =
    (select Max (NBRJOBS1. NBRJOBS_EFFECTIVE_DATE) as 'EffectDate '.
    of POSNCTL. NBRJOBS NBRJOBS1
    where NBRJOBS1. NBRJOBS_PIDM = NBRJOBS. NBRJOBS_PIDM
    and NBRJOBS1. NBRJOBS_POSN = NBRJOBS. NBRJOBS_POSN
    and NBRJOBS1. NBRJOBS_SUFF = NBRJOBS. NBRJOBS_SUFF
    and NBRJOBS1. NBRJOBS_SUFF <>'LS '.
    and NBRJOBS1. NBRJOBS_EFFECTIVE_DATE < = to_date('2011/11/15','yy/mm/dd'))
    order of NBRJOBS. NBRJOBS_PIDM

    Welcome to the forum!

    We don't know what you are trying to do.
    You want all of the columns in the rows where NBRJOBS_EFFECTIVE_DATE is the date limit before a given date (November 15, 2011 in this example) for all rows in the result set with this NBRJOBS_PIDM? If so, here is one way:

    with         GOT_R_NUM     as
    (
         select       NBRJOBS.NBRJOBS.*,
                NBRBJOB.NBRBJOB.*     -- You may have to give aliases, so that every column has a unique name
         ,       rank () over ( partition by  NBRJOBS.NBRJOBS_PIDM
                                   order by      NBRJOBS.NBRJOBS_EFFECTIVE_DATE     desc
                          )             as R_NUM
         from          POSNCTL.NBRBJOB NBRBJOB
         inner join      POSNCTL.NBRJOBS NBRJOBS       on    (NBRBJOB.NBRBJOB_PIDM = NBRJOBS.NBRJOBS_PIDM)
                                            and      (NBRBJOB.NBRBJOB_POSN = NBRJOBS.NBRJOBS_POSN)
                                      and      (NBRBJOB.NBRBJOB_SUFF = NBRJOBS.NBRJOBS_SUFF)
         where       NBRJOBS.NBRJOBS_SUFF             != 'LS'       -- Is this what you meant?
         and        NBRBJOB.NBRBJOB_CONTRACT_TYPE   ='P'
         and       NBRJOBS.NBRJOBS_EFFECTIVE_DATE  <= to_date ('2011/11/15', 'yyyy/mm/dd')
    )
    select       *     -- Or list all columns except R_NUM
    from       GOT_R_NUM
    where       R_NUM          = 1
    order by  NBRJOBS_PIDM
    ;
    

    Normally this site does not display the <>inequality operator; He thinks it's some kind of beacon.
    Whenever you post on this site, use the other inequality operator (equivalent), *! = *.

    I hope that answers your question.
    If not, post a small example of data (CREATE TABLE and INSERT, only relevant columns instructions) for all the tables involved and the results desired from these data.
    Explain, using specific examples, how you get these results from these data.
    Always tell what version of Oracle you are using.
    You will get better results faster if you always include this information whenever you have a problem.

  • Deliver the trigger, multi-table insert logging of errors

    I find that if I try to perform an insert multi-table with logging of errors on a table that has a trigger, then some violations of constraints result in a raised exception being as connected:
    < pre >
    SQL > select * from v version $;

    BANNER
    --------------------------------------------------------------------------------
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE 11.2.0.1.0 Production
    AMT for 32-bit Windows: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production

    SQL > create table t1 (primary key of all id ;)

    Table created.

    SQL > create table t2 (id integer, t1_id integer primary key,
    2 constraint t2_t1_fk foreign key (t1_id) refers to t1);

    Table created.

    SQL > exec dbms_errlog.create_error_log ("T2");

    PL/SQL procedure successfully completed.

    SQL > insert all
    2 in t2 (id, t1_id)
    3 values (x, y)
    4 errors in the journal in err$ _t2 limit unlimited rejection
    5. Select 1 x, 2 double y;

    0 rows created.

    SQL > create or replace trigger t2_trg
    2 before insert or update on t2
    3 for each line
    4 start
    5 zero;
    6 end;
    5 m

    Trigger created.

    SQL > insert all
    2 in t2 (id, t1_id)
    3 values (x, y)
    4 errors in the journal in err$ _t2 limit unlimited rejection
    5. Select 1 x, 2 double y;
    Insert all
    *
    ERROR on line 1:
    ORA-02291: integrity constraint (enhanced oil recovery. T2_T1_FK) violated - key parent not found
    < code >

    This does not seem to be a documented restriction. Anyone know if this is a bug?

    Hi Tony,.

    Looks like you ran into Bug 9539578: INSERT ALL AND TRIGGER CAUSES ERROR LOGGING to FAIL (ROLLBACK)

    Concerning
    Peter

  • Outer join, 3 tables

    Please see the attached link for table structures and data of the sample.

    There will be several lines in the table of SALES with different SALETYPEs. There may be several lines in the table RETURNS, corresponding to some of the points of SALE. RETURNS the table has a foreign key to the SALE. The report that I am trying to generate with a select sql statement must include a line for each type of sale (from table SALETYPE) and the sum of sale amounts corresponding to this type of sale of the SALES table. The table may not return the entries for all types of sales and the amount of Scripture must be reported as zero. The SQL I use is below, but does not work. I hope that I have explained this correctly. Please see the doc attached for typical data that I work with. Can someone please?

    https://spreadsheets.Google.com/pub?key=0AnDmnUJXOChwdGF2ZjdjdHFtMGF1MkJ3MWtjQ2JfUmc & hl = in & Single = true & gid = 0 & output = html

    Select SUM (s.amount) as sum_amount, t.sale_type from SALES s, SALETYPE t, r RETURNS
    where s.id = r.id
    and s.sale_type_id = t.id
    T.sale_type group;

    Published by: 801941 on October 12, 2010 15:02

    Hello - the second displays almost had. what you want to do is joining several tables at once - impossible with the syntax of the oracle, but possible if you use ANSI SQL.

    Wrote file afiedt.buf
    
      1  WITH s AS
      2   (SELECT 1 id, 1 sale_type_id, 10 amount   FROM dual
      3    UNION ALL
      4    SELECT 2, 1, 10  FROM dual
      5    UNION ALL
      6    SELECT 3, 2, 10   FROM dual
      7    UNION ALL
      8    SELECT 4, 2, 10   FROM dual
      9    UNION ALL
     10    SELECT 5, 3, 10    FROM dual
     11    UNION ALL
     12    SELECT 6, 4, 10 FROM dual),
     13  r AS
     14   (SELECT 2 sale_id   FROM dual
     15    UNION ALL
     16    SELECT 3 FROM dual
     17    UNION ALL
     18    SELECT 4 FROM dual),
     19  t AS
     20   (SELECT 1 sale_type_id, 100 sale_type    FROM dual
     21    UNION ALL
     22    SELECT 2, 200    FROM dual
     23    UNION ALL
     24    SELECT 3, 300    FROM dual
     25    UNION ALL
     26    SELECT 4, 400 FROM dual)
     27  SELECT nvl(SUM(s.amount),0) total_amount, t.sale_type
     28    FROM t
     29     join r on (1=1)
     30     left outer join s on (s.id = r.sale_id and s.sale_type_id = t.sale_type_id)
     31   --WHERE s.id(+) = r.sale_id
     32  --   AND s.sale_type_id(+) = t.sale_type_id
     33   GROUP BY t.sale_type
     34*  order by t.sale_type
    SQL> /
    
    TOTAL_AMOUNT  SALE_TYPE
    ------------ ----------
              10        100
              20        200
               0        300
               0        400
    
    4 rows selected.
    

    The two commented lines are what you are trying to achieve using the syntax of the oracle, but which will give you an error.

  • Join of tables?

    Hello


    My 1st question
    Sometimes i have hard time in deciding the weather to use equi join or left join or right join ?? 
    
    After looking at the data model i can understand how the tables can be joined on what attribute but i lack in making decision weather to use left join or right join for one to many or many to one relationships 
    
    I know the concept of right join and left join but i get confused in what scenario i need to use left join or right join and what join to use for one to many relationships or many to one relationships
    
    If you have any techniques or suggetions how to use them that will be great!!
    My 2nd question




    ___Table1___ TableA
    | | | |
    Table2, table3 table 4 < - TableC - TableB-|

    Table 1 a 1 of many relationships of table2, table 3, table 4

    I, e Table1-> table 2, table 3, table 4

    Table A has many relationships in table 1 B, i, e TableA-> table B

    Table B has 1 in-several in Table C, i, e table B-> table C

    Table C has many relationships in table 4, i, e 1 C table-> table 4


    I know the attributes to use to join these tables, but my question is what join what I use left join or right join or Equi join (I don't think I can use this)


    Something like that in my SQL query in where clause (I don't know if this is right).

    Where
    Table1. ID = table2. ID
    or table1.my_field = table3.id
    or table1.my_field = table4.id
    or tableA. ID = tableB.id---(ce que je dois opérateur OR ou opérateur AND???)
    or tableB.id = TableC.id
    or tablec.id = table4.id

    I don't know if this right or do I have to use the left join on right join or and or operator operator 'OR' is something I m really confued subject.




    Any advice greatly appriciated thank you!

    Published by: user642297 on May 12, 2010 09:49

    Published by: user642297 on May 12, 2010 09:51

    Apart from referring to various documents and examples...
    Use the following examples as 'Playground' and experience to get an idea of the various "joins".

    -- SETUP for examples...
    drop table A;
    drop table B;
    drop table C;
    
    create table a (ca int, sa varchar2(50));
    
    create table b (cb int, sb varchar2(50));
    
    create table c (cc int, sc varchar2(50));
    
    insert into A
    select * from
    (
    select level myid, to_char( to_date( level,'J'),'Jsp') mystr
    from dual connect by level < 11
    );
    commit;
    
    insert into B
    select * from
    (
    select level myid, to_char( to_date( level,'J'),'Jsp') mystr
    from dual connect by level < 21
    )
    where mod(myid,2) = 0;
    commit;
    
    insert into C
    select * from
    (
    select level myid, to_char( to_date( level,'J'),'Jsp') mystr
    from dual connect by level < 11
    )
    where myid < 6;
    commit;
    
    -- Verify the setup
    select * from A;
    
    select * from B;
    
    select * from C;
    
    -- **************************************************************
    -- Requirement EQUI JOIN 1. (AKA INNER JOIN)
    -- To select rows from A and MATCHING rows from B
    -- use A JOIN B or B JOIN A
    --
    -- ANSI SQL syntax
    select * from
    A JOIN B
    on (A.CA = B.CB)
    ;
    -- **** OR ****
    select * from
    B JOIN A
    on (A.CA = B.CB)
    ;
    -- OR Traditional Oracle syntax
    select * from A, B
    where A.CA = B.CB
    ;
    
    -- **************************************************************
    -- Requirement EQUI JOIN 2. (AKA INNER JOIN)
    -- To select rows from A and MATCHING rows from B and matching
    -- rows from C
    -- use A JOIN B JOIN C
    --
    -- ANSI SQL syntax
    select * from
    A JOIN B
    on (A.CA = B.CB)
    JOIN C
    on(B.CB = C.CC)
    ;
    -- OR Traditional Oracle syntax
    select * from A, B, C
    where A.CA = B.CB
      and B.CB = C.CC
    ;
    
    -- **************************************************************
    -- Requirement OUTER JOIN 1.
    -- To select ALL rows from A and ONLY MATCHING rows from B
    -- use A LEFT OUTER JOIN B or B RIGHT OUTER JOIN A
    --
    -- The columns for table B will have NULL value where a
    -- match for A is not found
    --
    -- ANSI SQL syntax
    select * from
    A LEFT OUTER JOIN B
    on (A.CA = B.CB)
    ;
    -- **** OR ****
    select * from
    B RIGHT OUTER JOIN A
    on (A.CA = B.CB)
    ;
    -- OR Traditional Oracle syntax
    select * from A, B
    where A.CA = B.CB(+)
    ;
    ----------------------------------------------------------
    -- The queries above are EQUIVALENT - return the same
    -- result set.
    -- **** However note the "order" in which the rows are
    --      returned by default.
    ----------------------------------------------------------
    
    -- **************************************************************
    -- Requirement OUTER JOIN 2.
    -- To select ALL rows from B and ONLY MATCHING rows from A
    -- use B LEFT OUTER JOIN A or A RIGHT OUTER JOIN B
    --
    -- The columns for table A will have NULL value where a
    -- match for B is not found
    --
    -- ANSI SQL syntax
    select * from
    B LEFT OUTER JOIN A
    on (A.CA = B.CB)
    ;
    -- **** OR ****
    select * from
    A RIGHT OUTER JOIN B
    on (A.CA = B.CB)
    ;
    -- Traditional Oracle syntax
    select * from A, B
    where A.CA(+) = B.CB
    ;
    
    -- **************************************************************
    -- Requirement OUTER JOIN 3.
    -- To select ALL rows from A and ONLY MATCHING rows from B
    -- AND select those rows from C that match rows from B
    --
    -- ANSI SQL syntax
    select * from
    A LEFT OUTER JOIN B
    on (A.CA = B.CB)
     LEFT OUTER JOIN C
    on (B.CB = C.CC)
    ;
    -- OR Traditional Oracle syntax
    select * from A, B, C
    where A.CA = B.CB(+)
      and B.CB = C.CC(+)
    ;
    ----------------------------------------------------------
    -- and So on...
    
    -- **************************************************************
    -- Requirement FULL JOIN 3.
    -- To select ALL rows from A and ALL rows from B
    -- AND MATCH the rows from A and B that match, but return even
    -- the unmatching rows.
    --
    -- ANSI SQL syntax
    select * from
    A FULL OUTER JOIN B
    on (A.CA = B.CB)
    ;
    -- OR Traditional Oracle syntax
    -- There is no equivalent for FULL OUTER join in traditional
    -- syntax. (Though it can be achieved using other means)
    -----------------------------------------------------------------
    

    VR,
    Sudhakar B.

  • BI multi evil SQL transaction

    After that we upgrade to OBIEE 10.1.3.3 7.8.2, our report does not work. The report is based on tables OPLT Siebel life sciences. I checked the RPD, it is almost exactly the same as in 7.8.2. However, the SQL code generated by the BI server in 10.1.3.3 contains a join that would return no records.
    Here are the two SQLs:

    In 7.8.2:

    Select distinct D1.c1 as c1,
    D1. C2 C2,
    D1. C3 as c3,
    D1. C4 as c4,
    D1. C5 as c5,
    D1. C6 as c6,
    D1. As c7 C7
    Of
    (select distinct T1027. PTCL_NUM C1,
    T10664. SITE_NUM C2,
    T52895. Name as c3,
    T52895. TODO_CD as c4,
    T52895. EVT_STAT_CD like c5,
    T52895. DOC_RCVD_DT as c6,
    T52895.comments as c7
    Of
    S_PTCL_SITE_LS T10664 / * Site of the Protocol * /,.
    S_CL_PTCL_LS T1027 / * protocols * /,.
    S_EVT_ACT T52895 / * activity * /.
    where (T10664. ROW_ID = T52895. CL_PTCL_ST_ID
    and T1027. ROW_ID = T10664. CL_PTCL_ID
    and T52895. SUBTYPE_CD = 'Document')
    ) D1
    order by c1, c2, c3, c4, c5, c6, c7


    In OBIEE 10.1.3.3, shows SQL as follows. The join ' T438245. ROW_ID = T443245. ROW_ID' is between 'S_EVT_ACT' and 'S_CL_PTCL_LS', their row_id would not match.

    Where should I look for the index to such a problem?


    Select distinct T438245. PTCL_NUM C1,
    T442683. SITE_NUM C2,
    T443245. TODO_CD as c3,
    T443245. Name as c4,
    T443245. EVT_STAT_CD like c5,
    T443245. DOC_RCVD_DT as c6,
    T443245.comments as c7
    Of
    S_PTCL_SITE_LS T442683 / * Site of the Protocol * /,.
    S_CL_PTCL_LS T438245 / * protocols * /,.
    S_EVT_ACT T443245 / * activity * /.
    where (T438245. ROW_ID = T442683. CL_PTCL_ID
    and T438245. ROW_ID = T443245. ROW_ID
    and T442683. ROW_ID = T443245. CL_PTCL_ST_ID
    and T443245. SUBTYPE_CD = 'Document')
    order by c1, c2, c3, c4, c5, c6, c7

    Thank you very much!

    Check the join in the physical layer between S_CL_PTCL_LS and S_EVT_AC.

    What you say (they do not match), they should not be reached. Ensure THAT RPD has only the correct joins so that the BI server can join your tables properly.
    I wander if RPD 7.8.2 the join was there but BI Server never used it, can you confirm for us?

Maybe you are looking for

  • HP will support the "Windows 7 Upgrade Program?

    For those not in the know, MS gives OEM (for example, HP) the ability to offer a free upgrade to Windows 7 for people who buy a Vista PC after July 1, 2009. I plan to do my next PC HP another and I would buy it sooner rather than later - but not if i

  • Satellite A40: How to reinsert the key on the keyboard

    Help... a key on my keyboard has extracted out.I knew nothing was broken.Does anyone know how to reinsert the key on the keyboard? Is there guidance on the internet?Or did someone knows how much cost a repair would be? It would take to leave my compu

  • My libraries to publish data disappeared!

    Hi people, This is not the first time that this has happened. I had a complete system collapse shortly after the first time, for a new installation of XP/LV made things OK for awhile. Things became a little strange with LV, so I decided that a uninst

  • Disable copy and move files/folders in windows xp

    I want to warn the user domain to copy files or folders in windows xp

  • Pavilion DV6-3183ee: Pavilion DV6-3183ee hard upgrade SSD

    HelloI'm not 100% sure on the exact model I have (I'm sure it's 3183ee) but the motherboard is 631044-001According to the laptop manual, he must take 160 GB SSD but it would work also with: Crucial BX100 250 GB SATA 6 Gbit/s 2.5 "SSD internal flash d