Join-types right & full outer join with Datasets

Hello
I use Crystal Reports XI Release 2 with ADO.NET Datasets as datasource. In the "Database-Expert" I try to set the "Link-Options". Unfortunately are the join-types "right outer join" and "full outer join" disabled.
- Is this because of the datasource Dataset?
- Is there e possibility to build the Dataset so I can use this two joins?
- If not, is it possible in a newer version?
Thanks, T.Fitzi

Hi
I think this is the problem. I don't connect directly to a database. My application (C#) provieds Crystal Report with a dataset. So all my data is in this dataset.
Are this joins in the new version stil disabled?
Regards, Thomas

Similar Messages

  • Full Outer Join Help Needed

    Hi All,
    I am new to crystal and my sql.
    l have 2 command objects in that i have a common column pos_no.Now i need to apply Fullouterjoin between pos_no,but in crystal we don,t have that option.
    So i saw some threads that we need to apply leftouterjoin union rightouterjoin to get FOJ in db level ,i tried ,but i don't have much knowledge in my sql.So can any one please apply FOJ between Pos_no of these two queries.
    Please help me i strucked here
    1st Query:
    select
    MIN(till_close.start_transaction_id) AS start_trans_id,
    MAX(till_close.end_transaction_id) AS end_trans_id,
    pos_config.pos_no,
    pos_config.name AS pos_name,
    SUM(transaction_tender.amount) AS EodDeposit
    FROM
    till_close
    LEFT OUTER JOIN employee ON (till_close.employee_id = employee.employee_id)
    INNER JOIN pos_config ON (till_close.pos_config_id = pos_config.pos_config_id)
    INNER JOIN transaction_tender ON (till_close.end_transaction_id = transaction_tender.transaction_id)
    INNER JOIN media_type ON (transaction_tender.media_type_id = media_type.media_type_id)
    WHERE
      DATE_FORMAT(till_close.transaction_date,'%d/%m/%Y') = DATE_FORMAT(STR_TO_DATE(?,'%d/%m/%Y'),'%d/%m/%Y')
    AND transaction_tender.media_type_id NOT IN (10000)
    GROUP BY
    pos_config.pos_no
    ORDER BY
    pos_config.pos_no
    2nd Query:
    select
    pos_config.pos_no,
    pos_config.name AS pos_name,
    SUM(CASE WHEN transaction.transaction_type_id=7 AND ((SELECT COUNT(transaction_id) FROM transaction_tender WHERE transaction_id = transaction.transaction_id  AND media_type_id IN (SELECT media_type_id FROM media_type WHERE tender_type_id=12) AND amount < 0 )>0) THEN 0
      WHEN  transaction_tender.balance < 0
      THEN transaction_tender.amount
      ELSE (transaction_tender.amount - transaction_tender.balance)
      END) AS net
    FROM
    TRANSACTION
    INNER JOIN transaction_tender ON (transaction.transaction_id = transaction_tender.transaction_id)
    INNER JOIN media_type ON (transaction_tender.media_type_id = media_type.media_type_id)
    INNER JOIN pos_config ON (transaction.pos_config_id = pos_config.pos_config_id)
    WHERE
    transaction.transaction_date = DATE_FORMAT(STR_TO_DATE(?, '%d/%m/%Y'), '%Y-%m-%d')
    AND transaction.transaction_type_id IN (1,5,7)
    AND transaction.transaction_status_id = 3
    AND transaction.is_training_mode = 0
    GROUP BY
    pos_config.pos_no

    hi Divya,
    i would definitely take the advice from the folks here on a rewrite of your commands into one command.
    since you've got 2 commands that are bringing back different results you may wish to consider bringing back the results from the 2nd command via a sub-query.
    the general idea of the query is below, but you'll need to consult your online help for your database and or your dba for the correct syntax for your situation.
    notes:
    1) the subselect is in the bold font and is defined as a result set in the join...again, please consult your database help or the appropriated forum for your database as your syntax may vary
    2) the fields in the subquery are then referenced in the select clause using the TT alias assigned to the result set in the join
    3) the full outer join i guessed that you wanted on the two pos_no fields
    4) if you do try to do this method and are looking on your database forum, do a search on "subquery multiple columns"
    cheers,
    jamie
    select
    MIN(till_close.start_transaction_id) AS start_trans_id,
    MAX(till_close.end_transaction_id) AS end_trans_id,
    pos_config.pos_no AS PC_pos_no,
    pos_config.name AS pos_name AS PC_pos_name,
    SUM(transaction_tender.amount) AS EodDeposit,
    TT.pos_no AS TT_pos_no,
    TT.pos_name AS TT_pos_name,
    TT.net
    FROM
    till_close
    LEFT OUTER JOIN employee ON (till_close.employee_id = employee.employee_id)
    INNER JOIN pos_config ON (till_close.pos_config_id = pos_config.pos_config_id)
    INNER JOIN transaction_tender ON (till_close.end_transaction_id = transaction_tender.transaction_id)
    INNER JOIN media_type ON (transaction_tender.media_type_id = media_type.media_type_id)
    FULL OUTER JOIN
    (select
    pos_config.pos_no,
    pos_config.pos_name,
    SUM(CASE WHEN transaction.transaction_type_id=7 AND ((SELECT COUNT(transaction_id) FROM transaction_tender WHERE transaction_id = transaction.transaction_id  AND media_type_id IN (SELECT media_type_id FROM media_type WHERE tender_type_id=12) AND amount < 0 )>0) THEN 0
      WHEN  transaction_tender.balance < 0
      THEN transaction_tender.amount
      ELSE (transaction_tender.amount - transaction_tender.balance)
      END) AS net
    FROM
    TRANSACTION
    INNER JOIN transaction_tender ON (transaction.transaction_id = transaction_tender.transaction_id)
    INNER JOIN media_type ON (transaction_tender.media_type_id = media_type.media_type_id)
    INNER JOIN pos_config ON (transaction.pos_config_id = pos_config.pos_config_id)
    WHERE
    transaction.transaction_date = DATE_FORMAT(STR_TO_DATE(?, '%d/%m/%Y'), '%Y-%m-%d')
    AND transaction.transaction_type_id IN (1,5,7)
    AND transaction.transaction_status_id = 3
    AND transaction.is_training_mode = 0
    GROUP BY
    pos_config.pos_no) AS TT
    ON TT.pos_no =  pos_config.pos_no
    WHERE
      DATE_FORMAT(till_close.transaction_date,'%d/%m/%Y') = DATE_FORMAT(STR_TO_DATE(?,'%d/%m/%Y'),'%d/%m/%Y')
    AND transaction_tender.media_type_id NOT IN (10000)
    GROUP BY
    pos_config.pos_no
    ORDER BY
    pos_config.pos_no

  • Query with FULL OUTER JOIN , help pleaseeeeeeeeeeee...

    Hi everyone,
    I'm trying to write a query for a report in Oracle SQL, but i just can't figure out how to do it.
    I'm using Oracle 10g release 1.0 database and i execute my queris in SQL* PLUS ( eventually i'm gonna use them in Oracle Report Builder ) .
    here's what i have:
    i have four tables that are used for our inventory application. lets call them INCOMMING , INCOMMING_ITEMS , OUTGOING , OUTGOING_ITEMS.
    as you may have guessed , INCOMMING_ITEMS is the detail table for INCOMMING ( joined by IID column) and also OUTGOING_ITEMS is the detail table for OUTGOING ( joined by OID column ).
    here is the structure of them :
    INCOMMING
    IID varchar2
    CDATE date
    INCOMMING_ITEM
    IID varchar2
    PART_NO number
    QTY number
    OUTGOING
    OID varchar2
    CDATE date
    OUTGOING_ITEM
    OID varchar2
    PART_NO number
    QTY number
    now , the query i want, should return part_no , cdate , sum of OUTGOING qty , sum of INCOMMING qty .
    the result of the query should be sth like this :
    part_no     cdate     O_qty     I_qty
    100     01/05/06     10     0
    100     01/05/07     20     60
    200     01/06/02     0     50
    300     01/06/02     30     40
    this means that for some dates and for some parts, i may not have INCOMMING or OUTGOING data, but if at least one of the 2 last columns has a non-zero data, i should show the row ( like the first and third rows of my example result), and if both have data for the same PART_NO and the same CDATE, both should be showed in the same row. ( like the second row in my example result)
    i tried so much and came up with several huge and also time consuming queries, but then i read abt FULL OUTER JOIN somewhere and tried using that. here is what i came up with :
    SELECT
    PART_NO , CDATE , sum(II.QTY) I_QTY , SUM (OI.QTY) O_QTY
    FROM
         (OUTGOING O INNER JOIN OUTGOING_ITEM OI USING ( OID ) )
    FULL OUTER JOIN
         (INCOMMING I INNER JOIN INCOMMING_ITEM II USING ( IID ) )
    ON ( I.CDATE = O.CDATE AND II.PART_NO = OI.PART_NO)
    WHERE
    I.CDATE = :PARAMETER1
    AND O.CDATE = :PARAMETER1
    GROUP BY
    PART_NO , CDATE
    this query is short and fast , but the results r not what i expected. i mean, although i have used FULL OUTER JOIN in the query , but the results i get r sth like this :
    part_no     cdate     O_qty     I_qty
    100     01/05/07     20     60
    300     01/06/02     30     40
    which means only the rows that has both values are returned.
    any change i make to this query would make the SQL* PLUS hang , like when i use the cartesian product of two large tables, so i guess my changes wheren't in the right direction.
    i think its possible to write this query using FULL OUTER JOIN syntax, but i just can't find it.
    Can anybody pleaseeeeeeeeeeeee help me?
    thanx in advance,
    Maryam.

    Note: I wrote this on the fly -- hope there is no syntax errors, otherwise forgive me -- but you get the idea..
    select
    fromUnionAll.cdate, fromUnionAll.part_no,
    sum(fromUnionAll.O_qty) O_qty,
    sum(fromUnionAll.I_qty) I_qty
    from
    select
    iinner.cdate, iinner.part_no, 0 O_qty, iinner.I_qty
    from
    select
    i.cdate, ii.part_no,
    /* added the case only for the extreme case when there is
    no record anywhere for the given CDATE in INCOMMING_item */
    sum( ( case when ii.qty is not null then ii.qty else 0 end) ) I_qty
    from
    incomming i,
    incomming_item ii
    where
    i.iid = ii.iid (+)
    group by i.cdate, ii.part_no
    ) iinner
    union all
    select
    oinner.cdate, oinner.part_no, oinner.O_qty, 0 I_qty
    from
    select
    o.cdate, oi.part_no,
    /* added the case only for the extreme case when there is
    no record anywhere for the given CDATE in OUTGOING_item */
    sum( ( case when oi.qty is not null then oi.qty else 0 end) ) O_qty
    from
    outgoing o,
    outgoing_item oi
    where
    o.oid = oi.oid (+)
    group by o.cdate, oi.part_no
    ) oinner
    ) fromUnionAll
    group by fromUnionAll.cdate, fromUnionAll.part_no;
    --Samson                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Union among multiple select queries with full outer join

    Hello everyone,
    I have 3 different select queries (used FULL Outer Join) which work fine. Now I want to add Union to the results among them and pick the selected columns from each query in the final result. while doing so, I am getting an error as "right parenthesis missing". I am quite sure, it is not the real cause. I guess might be issue with the query structure.
    select j.pod, j.hostname, portal.hostname,saasc.hostname,a3s.hostname from -- * from
    Select J.Pod,J.Hostname, P.Pod Portal_Pod,P.Hostname Portal_Hostname
    From Total_Pod J
    full outer join Portal_Tmp P On (J.Pod = P.Pod And J.Hostname = P.Hostname) as portal
    Union
    Select J.Pod,J.Hostname, s.Pod saasc_Pod,s.Hostname saasc_Hostname
    From Total_Pod J
    full outer join Saasc_Tmp S  On (J.Pod = s.Pod And J.Hostname = s.Hostname) as saasc
    Union
    Select J.Pod,J.Hostname, a.Pod a3s_Pod,a.Hostname a3s_Hostname
    From Total_Pod J
    Full Outer Join A3s_Tmp A  On (J.Pod = A.Pod And J.Hostname = A.Hostname) as a3s
    )p.s: select * from (INNER QUERY); also does not work.
    Any help appreciated.
    Thanks in advance.

    With T as
    (Select J.Pod,J.Hostname, P.Pod Portal_Pod,P.Hostname Portal_Hostname
    From Total_Pod J
    full outer join Portal_Tmp P On (J.Pod = P.Pod And J.Hostname = P.Hostname) ),
    U as
    (Select J.Pod,J.Hostname, s.Pod saasc_Pod,s.Hostname saasc_Hostname
    From Total_Pod J
    full outer join Saasc_Tmp S  On (J.Pod = s.Pod And J.Hostname = s.Hostname) ),
    V as
    (Select J.Pod,J.Hostname, a.Pod a3s_Pod,a.Hostname a3s_Hostname
    From Total_Pod J
    Full Outer Join A3s_Tmp A  On (J.Pod = A.Pod And J.Hostname = A.Hostname) )
    Select T.Pod,T.Hostname,nvl(T.Portal_Hostname,'Not Available') portal,nvl(U.Saasc_Hostname,'Not Available') saasc,NVL(V.A3s_Hostname,'Not Available') a3s From T,U,V
    Where T.Pod = U.Pod
    And U.Pod = V.Pod
    And T.Hostname = U.Hostname
    And U.Hostname = V.Hostname

  • Strange bug with Full Outer Join

    Hi guys,
    can you please confirm this behaviour on 11gR2? It used to work fine on 10gR1.
    Small test case:
    create table TEST_OBJECT_METADATA
      project_name  VARCHAR2(30 CHAR) not null,
      object_id     NUMBER not null
    create table TEST_OBJECT_INFO
      object_id          NUMBER not null,
      object_type        VARCHAR2(30) not null
    create table TEST_SUPPORTED_OBJECTS
      object_type    VARCHAR2(30 CHAR) not null,
      enabled        NUMBER(1));
    INSERT INTO TEST_OBJECT_METADATA VALUES ('NEW',1);
    INSERT INTO TEST_OBJECT_INFO VALUES (1, 'TABLE');
    INSERT INTO TEST_SUPPORTED_OBJECTS VALUES ('TABLE',1);
    COMMIT;When I execute the following query:
    WITH old_project AS
    (SELECT oi.object_type,
             oi.object_id
        FROM test_object_metadata om,
             test_object_info     oi
       WHERE om.object_id = oi.object_id
         AND project_name = 'OLD'),
    new_project AS
    (SELECT oi.object_type,
             oi.object_id
        FROM test_object_metadata om,
             test_object_info     oi
       WHERE om.object_id = oi.object_id
         AND project_name = 'NEW')
    SELECT src.object_type,
               t.enabled
      FROM (SELECT nvl(o.object_type, n.object_type) object_type
              FROM old_project o
              FULL OUTER JOIN new_project n
                ON o.object_id = n.object_id) src,
           test_supported_objects t
    WHERE src.object_type = t.object_type(+);I get the following output:
    OBJECT_TYPE     ENABLED
    TABLE             So, the outer join to test_supported_objects does not match.
    But if I force the FULL OUTER JOIN to run first using rownum:
    WITH old_project AS
    (SELECT oi.object_type,
             oi.object_id
        FROM test_object_metadata om,
             test_object_info     oi
       WHERE om.object_id = oi.object_id
         AND project_name = 'OLD'),
    new_project AS
    (SELECT oi.object_type,
             oi.object_id
        FROM test_object_metadata om,
             test_object_info     oi
       WHERE om.object_id = oi.object_id
         AND project_name = 'NEW')
    SELECT src.object_type,
               t.enabled
      FROM (SELECT nvl(o.object_type, n.object_type) object_type,
                           rownum
              FROM old_project o
              FULL OUTER JOIN new_project n
                ON o.object_id = n.object_id) src,
           test_supported_objects t
    WHERE src.object_type = t.object_type(+);I get the expected output:
    OBJECT_TYPE     ENABLED
    TABLE             1 Thanks in advance.

    Without mixing works fine:
    WITH old_project AS
    (SELECT oi.object_type,
             oi.object_id
        FROM test_object_metadata om,
             test_object_info     oi
       WHERE om.object_id = oi.object_id
         AND project_name = 'OLD'),
    new_project AS
    (SELECT oi.object_type,
             oi.object_id
        FROM test_object_metadata om,
             test_object_info     oi
       WHERE om.object_id = oi.object_id
         AND project_name = 'NEW')
    SELECT src.object_type,
           t.enabled
      FROM (SELECT nvl(o.object_type, n.object_type) object_type
              FROM old_project o,
                   new_project n   
              where  o.object_id = n.object_id(+)
              UNION
              SELECT nvl(o.object_type, n.object_type) object_type
              FROM old_project o,
                   new_project n   
              where  o.object_id(+) = n.object_id) src,
           test_supported_objects t
    WHERE src.object_type = t.object_type(+);but there shouldn't be any restrictions on mixing them, right?

  • [8i] Need help with full outer join combined with a cross-join....

    I can't figure out how to combine a full outer join with another type of join ... is this possible?
    Here's some create table and insert statements for some basic sample data:
    CREATE TABLE     my_tab1
    (     record_id     NUMBER     NOT NULL     
    ,     workstation     VARCHAR2(4)
    ,     my_value     NUMBER
         CONSTRAINT my_tab1_pk PRIMARY KEY (record_id)
    INSERT INTO     my_tab1
    VALUES(1,'ABCD',10);
    INSERT INTO     my_tab1
    VALUES(2,'ABCD',15);
    INSERT INTO     my_tab1
    VALUES(3,'ABCD',5);
    INSERT INTO     my_tab1
    VALUES(4,'A123',5);
    INSERT INTO     my_tab1
    VALUES(5,'A123',10);
    INSERT INTO     my_tab1
    VALUES(6,'A123',20);
    INSERT INTO     my_tab1
    VALUES(7,'????',5);
    CREATE TABLE     my_tab2
    (     workstation     VARCHAR2(4)
    ,     wkstn_name     VARCHAR2(20)
         CONSTRAINT my_tab2_pk PRIMARY KEY (workstation)
    INSERT INTO     my_tab2
    VALUES('ABCD','WKSTN 1');
    INSERT INTO     my_tab2
    VALUES('A123','WKSTN 2');
    INSERT INTO     my_tab2
    VALUES('B456','WKSTN 3');
    CREATE TABLE     my_tab3
    (     my_nbr1     NUMBER
    ,     my_nbr2     NUMBER
    INSERT INTO     my_tab3
    VALUES(1,2);
    INSERT INTO     my_tab3
    VALUES(2,3);
    INSERT INTO     my_tab3
    VALUES(3,4);And, the results I want to get:
    workstation     sum(my_value)     wkstn_name     my_nbr1     my_nbr2
    ABCD          30          WKSTN 1          1     2
    ABCD          30          WKSTN 1          2     3
    ABCD          30          WKSTN 1          3     4
    A123          35          WKSTN 2          1     2
    A123          35          WKSTN 2          2     3
    A123          35          WKSTN 2          3     4
    B456          0          WKSTN 3          1     2
    B456          0          WKSTN 3          2     3
    B456          0          WKSTN 3          3     4
    ????          5          NULL          1     2
    ????          5          NULL          2     3
    ????          5          NULL          3     4I've tried a number of different things, googled my problem, and no luck yet...
    SELECT     t1.workstation
    ,     SUM(t1.my_value)
    ,     t2.wkstn_name
    ,     t3.my_nbr1
    ,     t3.my_nbr2
    FROM     my_tab1 t1
    ,     my_tab2 t2
    ,     my_tab3 t3
    ...So, what I want is a full outer join of t1 and t2 on workstation, and a cross-join of that with t3. I'm wondering if I can't find any examples of this online because it's not possible....
    Note: I'm stuck dealing with Oracle 8i
    Thanks!!

    Hi,
    The query I posted yesterday is a little more complicated than it needs to be.
    Since my_tab2.workstation is unique, there's no reason to do a separate sub-query like mt1; we can join my_tab1 to my_tab2 and get the SUM all in one sub-query.
    SELECT       foj.workstation
    ,       foj.sum_my_value
    ,       foj.wkstn_name
    ,       mt3.my_nbr1
    ,       mt3.my_nbr2
    FROM       (     -- Begin in-line view foj for full outer join
              SELECT        mt1.workstation
              ,        SUM (mt1.my_value)     AS sum_my_value
              ,        mt2.wkstn_name
              FROM        my_tab1   mt1
              ,        my_tab2   mt2
              WHERE        mt1.workstation     = mt2.workstation (+)
              GROUP BY   mt1.workstation
              ,        mt2.wkstn_name
                    UNION ALL
              SELECT      workstation
              ,      0      AS sum_my_value
              ,      wkstn_name
              FROM      my_tab2
              WHERE      workstation     NOT IN (     -- Begin NOT IN sub-query
                                               SELECT      workstation
                                       FROM      my_tab1
                                       WHERE      workstation     IS NOT NULL
                                     )     -- End NOT IN sub-query
           ) foj     -- End in-line view foj for full outer join
    ,       my_tab3  mt3
    ORDER BY  foj.wkstn_name
    ,       foj.workstation
    ,       mt3.my_nbr1
    ,       mt3.my_nbr2
    ;Thanks for posting the CREATE TABLE and INSERT statements, as well as the very clear desired results!
    user11033437 wrote:
    ... So, what I want is a full outer join of t1 and t2 on workstation, and a cross-join of that with t3. That it, exactly!
    The tricky part is how and when to get SUM (my_value). You might approach this by figuring out exactly what my_tab3 has to be cross-joined to; that is, exactly what should the result set of the full outer join between my_tab1 and my_tab2 look like. To do that, take your desired results, remove the columns that do not come from the full outer join, and remove the duplicate rows. You'll get:
    workstation     sum(my_value)     wkstn_name
    ABCD          30          WKSTN 1          
    A123          35          WKSTN 2          
    B456          0          WKSTN 3          
    ????          5          NULL          So the core of the problem is how to get these results from my_tab1 and my_tab2, which is done in sub-query foj above.
    I tried to use self-documenting names in my code. I hope you can understand it.
    I could spend hours explaining different parts of this query in more detail, but I'm sure I'd waste some of that time explaining things you already understand. If you want an explanation of somthing(s) specific, let me know.

  • Using full outer join of subqueries named using with clause

    Hi,
    I am trying to create a view which is having 2 subqueries vol1 & vol2 with WITH clause. I am joining those 2 subqueries in the main query with FULL OUTER JOIN.
    When i compile that view in a tool like pl/sql developer, It has been compiled successfully.
    But when i call the view creation script from SQL command prompt, It is throwing error as
    from vol1 FULL JOIN vol2 o ON (vol1.ct_reference = vol2.ct_reference and vol1.table_name = vol2.table_name
    ERROR at line 29:
    ORA-00942: table or view does not exist
    Kindly advise whats going wrong.

    that's line 29. Maybe you get a better idea if you strip your operation of all the unneccessary elements until it works.
    There are some known bugs with subquery factoring (aka with clause) and also with ANSI join syntax, but it is hard to tell what happens here based on your description. But one thing is strange - if it is not a result of formatting (not formatting): I would expect the asterisk beneath the unknown table and not beneath the key word FULL.
    P.S.: my editor makes me think it's rather a proportional font thing. Have I already said that I don't like proportional font for SQL code examples?

  • Granting SELECT to user on VIEW with FULL OUTER JOIN fails?

    I have a quandary.
    Using Oracle 9i, I have created a simple view. When I perform a count on it, rows are returned.
    However, when I grant SELECT access to another user, they can't see the VIEW. The VIEW has a FULL OUTER JOIN operation in it.
    When I do the same thing using a regular join, it works.
    Any ideas why, please?
    SQL> conn ifsinfo/******@DB
    Connected.
    SQL> ed
    Wrote file afiedt.buf
      1  create view mctest3 as
      2  select
      3   vc.idcus ,
      4   ci.customer_id
      5  from
      6   ifsapp.vmo_company vc
      7  full outer join
      8   ifsapp.customer_info ci
      9  on
    10*  vc.custno = ci.customer_id
    SQL> /
    View created.
    SQL> select count(*) from mctest3;
      COUNT(*)
         73994
    SQL> GRANT SELECT ON MCTEST3 TO IFSAPP WITH GRANT OPTION;
    Grant succeeded.
    SQL> CONN IFSAPP/******@DB
    Connected.
    SQL> select count(*) from IFSINFO.MCTEST3;
    select count(*) from IFSINFO.MCTEST3
    ERROR at line 1:
    ORA-00942: table or view does not existbut with regular join:
    SQL> conn ifsinfo/******@DB
    Connected.
    SQL> create view mctest4 as
      2    select
      3     vc.idcus ,
      4     ci.customer_id
      5    from
      6     ifsapp.vmo_company vc, ifsapp.customer_info ci
      7    where vc.custno = ci.customer_id;
    View created.
    SQL> select count(*) from mctest4;
      COUNT(*)
         44269
    SQL> GRANT SELECT ON MCTEST4 TO IFSAPP WITH GRANT OPTION;
    Grant succeeded.
    SQL> conn ifsapp/******@DB
    Connected.
    SQL> select count(*) from IFSINFO.MCTEST4;
      COUNT(*)
         44269

    Hi,
    >>SQL> conn ifsinfo/******@DB
    Connected.
    SQL> ed
    Wrote file afiedt.buf
    1 create view mctest3 as
    2 select
    3 vc.idcus ,
    4 ci.customer_id
    5 from
    6 ifsapp.vmo_company vc
    7 full outer join
    8 ifsapp.customer_info ci
    9 on
    10* vc.custno = ci.customer_id
    SQL> /
    According to Note:244315.1, it is not possible to make a FULL OUTER JOIN on views owned by another user at the 9i version of Oracle. As above, do not use FULL OUTER JOIN on views owned by another user. Try to use outer join operator (+), and/or UNIONS instead.
    Cheers

  • Repalcing UNIOn with full outer Join

    I have a query wihch looks like ,
    select colA,colB ,colC, coldD from A,B,C,D
    where (some join conditions)
    union
    select colA,colB ,colC, NULL from A,B,C
    where (some join conditions)
    This query is posing us serious performance issues and we want to tune the query.
    SO to remove the UNION operator we want to use FULL JOIN.
    Can you please let us know how to frame the full outer join in the above query,so that the result set intact.
    Thanks Much

      Here goes my first query that uses UNION :
    SELECT  from_it.seq_routing,
           from_it.milestone_routing_dt,
           from_it.milestone_type_desc,
           to_it.seq_routing,
           to_it.milestone_routing_dt,
           to_it.milestone_type_desc,
           to_it.delay_flag,
           to_it.acceptable_delay_flag,
           TAB_A.calendar_minutes, TAB_A.business_minutes,
           TAB_A.due_date, TAB_A.late_minutes,
           TAB_A.delay_concat_comments,TAB_C.TAB_C_key,
           TAB_C.pcd,TAB_C.ssn,
           mmp.MEASURE_NAME,
           api.METRICS_PARAMETER_KEY,
    api.METRICS_PARAMETER_PRODUCT_KEY,
    crt.JUSTIFICATION_CD,
    crt.JUSTIFICATION_DESC,
    crt.ROUTING_USER_SITE_DESC
      FROM TAB_A, TAB_B from_it, TAB_B to_it,
      TAB_C, TAB_E,TAB_D mmp,TAB_F api, TAB_G crt
    WHERE from_it.TAB_B_key =
                                      TAB_A.from_TAB_B_key
       AND to_it.TAB_B_key =
                                        TAB_A.to_TAB_B_key
       ANDTAB_C.TAB_C_key = from_it.TAB_C_key
       andTAB_C.TAB_C_key = to_it.TAB_C_key
       and TAB_E.pck =crt.pck
       and to_it.SEQ_ROUTING  =crt.SEQ_ROUTING
       and TAB_E.pcd =TAB_C.pcd
       and TAB_E.ssn =TAB_C.ssn
       andTAB_C.END_DT = TO_DATE('12/31/9999', 'MM/DD/YYYY')
       and TAB_A.METRICS_MEASURE_KEY =mmp.METRICS_MEASURE_KEY
       andapi.END_DT = TO_DATE('12/31/9999', 'MM/DD/YYYY')
       andTAB_C.TAB_C_key =api.TAB_C_KEY
       andapi.PARAMETER_TYPE = 'IN'
    and TAB_A.end_dt = TO_DATE('12/31/9999', 'MM/DD/YYYY')
    and CRT.end_dt  = TO_DATE('12/31/9999', 'MM/DD/YYYY')
    UNION
    SELECT  from_it.seq_routing,
           from_it.milestone_routing_dt,
           from_it.milestone_type_desc,
           to_it.seq_routing,
           to_it.milestone_routing_dt,
           to_it.milestone_type_desc,
           to_it.delay_flag,
           to_it.acceptable_delay_flag,
           TAB_A.calendar_minutes, TAB_A.business_minutes,
           TAB_A.due_date, TAB_A.late_minutes,
           TAB_A.delay_concat_comments,TAB_C.TAB_C_key,
           TAB_C.pcd,TAB_C.ssn,
           mmp.MEASURE_NAME,
           api.METRICS_PARAMETER_KEY,
    api.METRICS_PARAMETER_PRODUCT_KEY,
    NULL, NULL, NULL
      FROM TAB_A, TAB_B from_it, TAB_B to_it,
      TAB_C, TAB_E,TAB_D mmp,TAB_F api
    WHERE from_it.TAB_B_key =
                                      TAB_A.from_TAB_B_key
       AND to_it.TAB_B_key =
                                        TAB_A.to_TAB_B_key
       ANDTAB_C.TAB_C_key = from_it.TAB_C_key
       andTAB_C.TAB_C_key = to_it.TAB_C_key
       and TAB_E.pcd =TAB_C.pcd
       and TAB_E.ssn =TAB_C.ssn
       andTAB_C.END_DT = TO_DATE('12/31/9999', 'MM/DD/YYYY')
       and TAB_A.METRICS_MEASURE_KEY =mmp.METRICS_MEASURE_KEY
       andapi.END_DT = TO_DATE('12/31/9999', 'MM/DD/YYYY')
       andTAB_C.TAB_C_key =api.TAB_C_KEY
       andapi.PARAMETER_TYPE = 'IN'
       and to_it.SEQ_ROUTING is null
    and TAB_A.end_dt = TO_DATE('12/31/9999', 'MM/DD/YYYY')
    And the one with OUTER JOIN used :
    SELECT  from_it.seq_routing,
           from_it.milestone_routing_dt,
           from_it.milestone_type_desc,
           to_it.seq_routing,
           to_it.milestone_routing_dt,
           to_it.milestone_type_desc,
           to_it.delay_flag,
           to_it.acceptable_delay_flag,
           TAB_A.calendar_minutes, TAB_A.business_minutes,
           TAB_A.due_date, TAB_A.late_minutes,
           TAB_A.delay_concat_comments,TAB_C.TAB_C_key,
           TAB_C.pcd,TAB_C.ssn,
           mmp.MEASURE_NAME,
           api.METRICS_PARAMETER_KEY,
    api.METRICS_PARAMETER_PRODUCT_KEY,
    crt.JUSTIFICATION_CD,
    crt.JUSTIFICATION_DESC,
    crt.ROUTING_USER_SITE_DESC
      FROM TAB_A  JOIN
      TAB_B from_it
      on  from_it.TAB_B_key =
                                      TAB_A.from_TAB_B_key
                      and TAB_A.end_dt = TO_DATE('12/31/9999', 'MM/DD/YYYY')
             JOIN
      TAB_B to_it
      ON to_it.TAB_B_key =
                                        TAB_A.to_TAB_B_key
                        JOINTAB_C
    ONTAB_C.TAB_C_key = from_it.TAB_C_key
    ANDTAB_C.TAB_C_key = to_it.TAB_C_key    
    andTAB_C.END_DT = TO_DATE('12/31/9999', 'MM/DD/YYYY')                
      JOINTAB_D mmp
      ON TAB_A.METRICS_MEASURE_KEY =mmp.METRICS_MEASURE_KEY
      JOIN TAB_E
      ON  TAB_E.pcd =TAB_C.pcd
       and TAB_E.ssn =TAB_C.ssn
      -- and TAB_E.ssn = 'PFEARG'
    JOINTAB_F api
    ON   TAB_C.TAB_C_key =api.TAB_C_KEY
       andapi.PARAMETER_TYPE = 'IN'
       andapi.END_DT = TO_DATE('12/31/9999', 'MM/DD/YYYY')
      LEFT

  • Ora-22905:cannot access rows from a non-nested ...(during full outer join)

    Greetings Gurus,
    I'm getting an ORA-22905 when I try and do a full outer join in the following function. If I include the commented lines in the perstren_diff_recs2 function I get the error. Both halfs of the union query work by themselves. When I union them bam error. Also, when I use the full outer join syntax the Oracle session craps the bed with a end of file communication error. That is why I'm using the simulated full outer join.
    My goal was to abstract the XML in my queries. The results from the pipelined function is a delta between what is in the XML document and a relational base table.
    Derrick
    CREATE OR REPLACE PACKAGE XML_UTILS is
    TYPE perstren_typ is record (
    uic varchar2(6),
    tpers varchar2(2),
    deply varchar2(6),
    secur varchar2(1),
    struc number(4),
    auth number(4)
    TYPE perstren_diff_typ is record (
    uic           varchar2(6),
    transaction_type char(1),
    tpers           varchar2(2),
    deply           varchar2(6),
    secur           varchar2(1),
    struc           number(4),
    auth           number(4)
    TYPE perstrenSet is table of perstren_typ;
    TYPE perstrenDiffSet is table of perstren_diff_typ;
    function perstren_recs (uic varchar2) return perstrenSet pipelined;
    function perstren_diff_recs2 (uic varchar2) return perstrenDiffSet pipelined;
    end;
    CREATE OR REPLACE PACKAGE BODY XML_UTILS is
    function perstren_diff_recs2 (uic varchar2) return perstrenDiffSet pipelined is
    cursor perstren_recs_cur(in_uic varchar2) is
    select p.uic, p.tpers, p.deply, P.secur, p.struc,p.auth,
    doc.uic as xmluic,
    doc.tpers as xmltpers,
    doc.deply as xmldeply,
    doc.secur as xmlsecur,
    doc.struc as xmlstruc,
    doc.auth as xmlauth
    from perstren_bac p left outer join
    table(xml_utils.perstren_recs(in_uic)) doc
    on (p.uic = doc.uic and
    p.tpers = doc.tpers and
    p.deply = doc.deply)
    where p.uic = in_uic;
    -- union
    -- select p.uic, p.tpers, p.deply, P.secur, p.struc,p.auth,
    -- doc.uic as xmluic,
    -- doc.tpers as xmltpers,
    -- doc.deply as xmldeply,
    -- doc.secur as xmlsecur,
    -- doc.struc as xmlstruc,
    -- doc.auth as xmlauth
    -- from perstren_bac p right outer join
    -- table(xml_utils.perstren_recs(in_uic)) doc
    -- on (p.uic = doc.uic and
    -- p.tpers = doc.tpers and
    -- p.deply = doc.deply)
    -- where doc.uic = in_uic;
    out_rec perstren_diff_typ;
    begin
    for cur_rec in perstren_recs_cur(uic) loop
    if cur_rec.xmldeply is not null and cur_rec.xmltpers is not null then
    out_rec.uic := cur_rec.xmluic;
    out_rec.tpers := cur_rec.xmltpers;
    out_rec.deply := cur_rec.xmldeply;
    out_rec.secur := cur_rec.xmlsecur;
    out_rec.struc := cur_rec.xmlstruc;
    out_rec.auth := cur_rec.xmlauth;
    else
    out_rec.uic := cur_rec.uic;
    out_rec.tpers := cur_rec.tpers;
    out_rec.deply := cur_rec.deply;
    out_rec.secur := cur_rec.secur;
    out_rec.struc := cur_rec.struc;
    out_rec.auth := cur_rec.auth;
    end if;
    if cur_rec.uic is not null and cur_rec.xmldeply is not null and cur_rec.xmltpers is not null and (
    nvl(cur_rec.secur,'XX') != nvl(cur_rec.xmlsecur,'XX') or
    nvl(cur_rec.struc,9999) != nvl(cur_rec.xmlstruc,9999) or
    nvl(cur_rec.auth,9999) != nvl(cur_rec.xmlauth,9999)) then
    out_rec.transaction_type :='U';
    elsif cur_rec.uic is null and cur_rec.xmldeply is not null then
    out_rec.transaction_type :='I';
    elsif cur_rec.uic is not null and cur_rec.xmldeply is null then
    out_rec.transaction_type :='D';
    else
    out_rec.transaction_type :='O';
    end if;
    PIPE row (out_rec);
    end loop;
    exception
    when others then
    if perstren_recs_cur%isopen then
    close perstren_recs_cur;
    end if;
    raise;
    return;
    end;
    function perstren_recs (uic varchar2) return perstrenSet pipelined is
    cursor perstren_recs_cur(in_uic varchar2) is
    select uic,
    extractvalue(Column_value,'/PERSTREN/TPERS') as TPERS,
    extractvalue(Column_value,'/PERSTREN/DEPLY') as DEPLY,
    extractvalue(Column_value,'/PERSTREN/SECUR') as SECUR,
    extractvalue(Column_value,'/PERSTREN/STRUC') as STRUC,
    extractvalue(Column_value,'/PERSTREN/AUTH') as AUTH
    from test_ref ref,
    table(XMLSequence(extract(ref.XML_DOC,'/RasDataSet/PerstrenList/PERSTREN'))) per
    where ref.uic = in_uic;
    out_rec perstren_typ;
    begin
    open perstren_recs_cur(uic);
    loop
    fetch perstren_recs_cur into out_rec;
    exit when not perstren_recs_cur%FOUND;
    PIPE row (out_rec);
    end loop;
    close perstren_recs_cur;
    exception
    when others then
    if perstren_recs_cur%isopen then
    close perstren_recs_cur;
    end if;
    raise;
    return;
    end;
    end;

    Oracle bug when executing the query in a function

  • Full outer Join:ORA-01790

    Hi All,
    The issue may be silly, but we cant make it out:
        DB : Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - ProdWe are running the below query with no issues:
    select t1.text,t2.text text2,t1.line,decode(upper(t1.text),upper(t2.text),1,0) flg
    from
       (select text,row_number() over(order by line) line
        from user_source
       where name = 'COLL_MVIEW_REFRESH_PROC_LBK'
       and replace(trim(text),chr(10)) is not null
       ) t1,
       (select text ,row_number() over(order by line) line
        from user_source
        where name = 'COLL_MVIEW_REFRESH_PROC'
        and trim(replace(text,chr(10))) is not null) t2
    where t1.line = t2.lineBut when trying for an outer join it is giving error like
    ORA-01790: expression must have same datatype as corresponding expressionOuter Join Query:
    select t1.text,t2.text,t1.line,decode(upper(t1.text),upper(t2.text),1,0) flg
    from
       (select text,row_number() over(order by line) line
        from user_source
        where name = 'COLL_MVIEW_REFRESH_PROC_LBK'
        and replace(trim(text),chr(10)) is not null
        ) t1 full outer join
        (select text ,row_number() over(order by line) line
        from user_source
        where name = 'COLL_MVIEW_REFRESH_PROC'
        and trim(replace(text,chr(10))) is not null) t2
    on( t1.line = t2.line )Any idea what is wrong here?
    Thanks,
    Jeneesh

    Not sure what is wrong with your version. It might have to do with row_number not working on an empty row (outer joined).
    How about this alternative?
    The approach is a bit different, but it uses only one access to the user_source view.
    select s.lineNo, min(s.text1) text1, min(s.text2) text2, decode(upper(min(s.text1)), upper(min(s.text2)), 1, 0) flag
    from
    (select decode(u.name, 'COLL_MVIEW_REFRESH_PROC_LBK', u.text) text1
           ,decode(u.name, 'COLL_MVIEW_REFRESH_PROC'
    , u.text) text2
           ,u.name,
            row_number() over (partition by u.name order by u.line) lineNo
    from user_source u
    where u.name in ('COLL_MVIEW_REFRESH_PROC_LBK','COLL_MVIEW_REFRESH_PROC'
    /* and u.TYPE = 'PROCEDURE' */
    and replace(trim(u.text),chr(10)) is not null
    ) s
    group by s.lineNo
    order by s.lineNo;Edited by: Sven W. on Nov 18, 2008 5:24 PM

  • SQL Query Assistance Required for Full Outer Join

    Hi,
    Lets say I have two tables, i.e:
    TAB_A (colA1, colA2, colA3, colA4)
    TAB_B (colB1, colB2, colB3, colB4) where colB2 is a FK to colA1
    I am after an SQL query that will cater for both the following two scenarios.
    Scenario 1:
    TAB_A has two rows of data, i.e
    (1, ABC100, 1, WG_A)
    (2, ABC100, 2, WG_B)
    TAB_B has one row of data, i.e
    (1, 1, EMP_222, 4)
    I use the following SQL:
    select a.*, b.*
    from tab_a a FULL OUTER JOIN tab_b b ON (a.colA1 = b.colB2)
    where a.colA2 = 'ABC100'
    This returns two rows:
    1, ABC100, 1, WG_A, 1, 1, EMP_222, 4
    2, ABC100, 2, WG_B
    Now, what I actually would like my query to do is actually only return the row where a tab_b record exists, i.e, should only return one record:
    1, ABC100, 1, WG_A, 1, 1, EMP_222, 4
    This I can achieve by using a RIGHT OUTER JOIN instead above, but this causes issue with my scenario 2, which is the following set-up
    Scenario 2:
    TAB_A has only one row of data this time, i.e
    (2, ABC100, 2, WG_B)
    TAB_B has no data at all this time
    This returns no rows but I actually now want this single record from tab_a returned.
    I basically require an SQL query that will cater for both the top 2 scenarios, i.e, if a tab_b record exists from the outer join then only return this record along with tab_a data. If a tab_b record doesn't exist, then only return the tab_a record.
    Hope the above makes sense.
    Thanks.

    Is it what you need (not very elegant) ?
    SQL> select * from t_outer;
            ID CODE
             1 100
             2 100
    SQL> select * from t_inner;
    no rows selected
    SQL> with tab1 as (
      2  select a.id a_id, a.code, b.id b_id from t_outer a join t_inner b on
      3  (a.id = b.id and a.code = '100'))
      4  select * from tab1
      5  union all
      6  select a.*, null from t_outer a where not exists (
      7  select 1 from tab1)
      8  and a.code = '100'
      9  /
          A_ID CODE             B_ID
             1 100
             2 100
    SQL> insert into t_inner values(2);
    1 row created.
    SQL> with tab1 as (
      2  select a.id a_id, a.code, b.id b_id from t_outer a join t_inner b on
      3  (a.id = b.id and a.code = '100'))
      4  select * from tab1
      5  union all
      6  select a.*, null from t_outer a where not exists (
      7  select 1 from tab1)
      8  and a.code = '100'
      9  /
          A_ID CODE             B_ID
             2 100                 2
    Rgds.

  • Are Multiproviders union or Full outer Joins of their InfoProviders?

    I was modeling an heterogeneous Multiprovider and thinking about the expected result set of my query. Looking at SAP note 379736, we can see that's really doing a full outer join sql operation, not an Union. Am I thinking right about that?
    Regards,
    André Rodrigues
    Edited by: André Rodrigues on Aug 3, 2011 3:03 PM

    Yes you're right, this is not really an union nor a full outer join but sometimes simplifying things can make them more understandable...
    UNION=
    Combines the results of two or more queries into a single result set that includes all the rows that belong to all queries in the union. The UNION operation is different from using joins that combine columns from two tables.
    The following are basic rules for combining the result sets of two queries by using UNION:
    The number and the order of the columns must be the same in all queries.
    The data types must be compatible.
    FULL OUTER JOIN=
    Specifies that a row from either the left or right table that does not meet the join condition is included in the result set, and output columns that correspond to the other table are set to NULL. This is in addition to all rows typically returned by the INNER JOIN.
    Quote from http://msdn.microsoft.com/en-us/library

  • FULL OUTER JOIN In InfoSet

    Hi, all
    Is it possible to make FULL OUTER JOIN in BI InfoSet?
    If no, another question - is it possible to switch base InfoProvider? I have an InfoSet with InfoCube1 and DSO1 which I can outer join. I want to outer join InfoCube1 , not DSO1 that's why I need to switch them in the InfoSet.

    Hi,
       In BI 7.0 Infoset has given chance to include an Info cube also,maximum you can include 2 info Cubes only in a infoset.
    check the below link which helps you in understanding of the join conditions so that you can apply to your scenario.
    http://help.sap.com/saphelp_nw2004s/helpdata/en/f1/713c3b35703079e10000000a114084/content.htm
    http://help.sap.com/saphelp_nw2004s/helpdata/en/67/7e4b3eaf72561ee10000000a114084/content.htm
    Regards,
    Praveena.

  • Full outer join ---  bug? Urgent

    Hi,
    I have a simple mapping using 2 source tables and doing an full outer join. While executing the mapping it is throwing me out with an error --
    Starting Execution LOAD_SAP
    Starting Task LOAD_SAP
    ORA-01790: expression must have same datatype as corresponding expression
    ORA-02063: preceding line from ODSD@LOC_TGT_LOC_ODSD
    ORA-06512: at "DWH_USER.LOAD_SAP", line 12
    ORA-06512: at "DWH_USER.LOAD_SAP", line 481
    ORA-06512: at "DWH_USER.LOAD_SAP", line 795
    ORA-06512: at "DWH_USER.LOAD_SAP", line 1973
    ORA-06512: at line 1
    Completing Task LOAD_SAP
    Completing Execution LOAD_SAP
    The SQL generated at line 12 is -
    CURSOR "JOIN_c" IS
    SELECT
    /*+ DRIVING_SITE("CONNECTION_LOC_TGT_LOC_ODSD") */
    "CONNECTION_LOC_TGT_LOC_ODSD"."END_USER_CUST_ID" "END_USER_CUST_ID",
    "SERVICE_LOC_TGT_LOC_ODSD"."SERVICE_NAME" "SERVICE_NAME",
    "CONNECTION_LOC_TGT_LOC_ODSD"."CE_CLLI" "CE_CLLI",
    "CONNECTION_LOC_TGT_LOC_ODSD"."PE_CLLI" "PE_CLLI"
    FROM "ODS"."CONNECTION"@"ODSD"@"LOC_TGT_LOC_ODSD" "CONNECTION_LOC_TGT_LOC_ODSD"
    FULL OUTER JOIN "ODS"."SERVICE"@"ODSD"@"LOC_TGT_LOC_ODSD" "SERVICE_LOC_TGT_LOC_ODSD" ON ("CONNECTION_LOC_TGT_LOC_ODSD"."END_USER_CUST_ID" = "SERVICE_LOC_TGT_LOC_ODSD"."END_USER_CUST_ID") ;
    If I replace the Full outer join with an equi join everything works fine. The SQL generated with an equi-join is ---
    SELECT
    /*+ DRIVING_SITE("CONNECTION_LOC_TGT_LOC_ODSD") */
    "CONNECTION_LOC_TGT_LOC_ODSD"."END_USER_CUST_ID" "END_USER_CUST_ID",
    "SERVICE_LOC_TGT_LOC_ODSD"."SERVICE_NAME" "SERVICE_NAME",
    "CONNECTION_LOC_TGT_LOC_ODSD"."CE_CLLI" "CE_CLLI",
    "CONNECTION_LOC_TGT_LOC_ODSD"."PE_CLLI" "PE_CLLI"
    FROM "ODS"."CONNECTION"@"ODSD"@"LOC_TGT_LOC_ODSD" "CONNECTION_LOC_TGT_LOC_ODSD",
    "ODS"."SERVICE"@"ODSD"@"LOC_TGT_LOC_ODSD" "SERVICE_LOC_TGT_LOC_ODSD" WHERE ( "CONNECTION_LOC_TGT_LOC_ODSD"."END_USER_CUST_ID" = "SERVICE_LOC_TGT_LOC_ODSD"."END_USER_CUST_ID" );
    We are using Oracle 9.2.0.4 AND OWB Clinet 9.2.0.2.8 and runtime repository 9.2.0.2.0.
    Any help on this appreciated?

    The discussion on this thread has moved to the later thread Problem with JOINs
    Nikolai

Maybe you are looking for