SQL for View Definition using outer join

Hello everyone,
I am creating a view using the statement below
SELECT *
FROM table_a A
,table_b B
,table_c C
WHERE A.sg_code = B.sg_code and
B.st_code = 'E' and
A.sg_code = C.sg_code(+) and
C.st_code = 'T'
The structure of the view is as follows
View
sg_code| Name | start_date | end_date |
1 | Test |13-03-2008 | NULL |
Table_a
sg_code,Name
Table_b
sg_code,st_code,actual_date
the view can have a null for the column 'end_date'
This means there will not be a record inserted in the Table_b for end_date=null, there will only be a record for actual_date=start_date
In this scenario when I query the view I am not seeing the newly created record just because there is a condition "C.st_code = 'T'" with the outer join on the sg_code.
When I look into the individual tables I see the records.
Table A
Pg_code,Name
1 Test
Table B
Id pg_code As_of_date
1 1 13-03-2008
How should I modify my view definition so that I can query the view even if there is a null for 'end_date'
Thanks
fm

the last line should be:
C.st_code(+) = 'T'
by failing to include the (+) on that line, you made it NOT an outer join. an outer joined table must be outer joined on every where criteria, including to constants.

Similar Messages

  • 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

  • How to use outer join condition in my below query.

    Hi All,
    How to use outer join condition in my below query.
    In the table  APPS_JP.GEDIS_OFFER_HEADER goh I have more records
    in the table APPS_JP.GEDIS_ORDER_BUILDS gob I have less number of records.
    I want all the records from APPS_JP.GEDIS_OFFER_HEADER goh
    including other conditions.
    I have tried goh.OFFER_NO=gob.OFFER_NO(+) but same result.
    [code]SELECT   GOH.ORIG_SYSTEM,
               gsp.USER_NAME,
               goh.ORDER_NO,
               goh.OMEGA_ORDER_NUMBER,
               goh.ORDER_TYPE,
               gc.CUSTOMER_ID,
               gc.OMEGA_CUSTOMER_NUMBER,
               CASE WHEN gc.PRIVATE = 'N' THEN gc.CUSTOMER_NAME ELSE '' END
                  AS COMPANY_NAME,
               goh.ORDER_STATUS,
               goh.TOTAL_SELLING_PRICE,
               goh.TOTAL_MARGIN,
                  ga1.ADDRESS1
               || ','
               || ga1.ADDRESS2
               || ','
               || ga1.ADDRESS3
               || ','
               || ga1.POSTAL_CODE
               || ','
               || ga1.CITY
                  AS SHIPPING_ADDRESS,
                  ga2.ADDRESS1
               || ','
               || ga2.ADDRESS2
               || ','
               || ga2.ADDRESS3
               || ','
               || ga2.POSTAL_CODE
               || ','
               || ga2.CITY
                  AS BILLING_ADDRESS,
               ga.ADDRESS_ID,
               gol.DESCRIPTION,
               APPS_JP.TZ.to_local_date (goh.OFFER_DATE, goh.OFFER_DATE_UTC)
                  AS OFFER_DATE,
               gc.LEVEL_8,
               goh.NO_OF_BUILDS,
               gob.SFDC_ID,
               goh.PURCHASE_ORDER_NO AS PO,
               gc1.CUSTOMER_NAME AS END_USAGE,
               gol.LOB,
               goh.TOTAL_MARGIN_PCT,
               goh.TOTAL_DISCOUNT,
               goh.TOTAL_DISCOUNT_PCT
        FROM   APPS_JP.GEDIS_OFFER_HEADER goh,
               APPS_JP.GEDIS_ORDER_BUILDS gob,
               APPS_JP.GEDIS_ORDER_LINES gol,
               APPS_JP.GEDIS_OFFER_RELATED_CUSTOMER gorc,
               APPS_JP.GEDIS_OFFER_RELATED_CUSTOMER ship,
               APPS_JP.GEDIS_OFFER_RELATED_CUSTOMER bill,
               APPS_JP.GEDIS_CUSTOMER gc,
               APPS_JP.GEDIS_CUSTOMER gc1,
               APPS_JP.GEDIS_CONTACT gct,
               APPS_JP.GEDIS_ADDRESS ga,
               APPS_JP.GEDIS_ADDRESS_NORM ga1,
               APPS_JP.GEDIS_ADDRESS_NORM ga2,
               (SELECT   DISTINCT SALESPERSON_ID, USER_NAME
                  FROM   APPS_JP.GEDIS_SALESPERSON
                 WHERE   SALESPERSON_ID IN
                               (SELECT   TO_NUMBER (COLUMN_VALUE) AS SALESPERSON_ID
                                  FROM   TABLE (APPS_GLOBAL.SplitString ('337309'))))
               gsp
       WHERE       goh.ORDER_NO <> 0
               AND goh.OFFER_NO <> 0
               AND goh.OFFER_NO=gol.OFFER_NO
               AND gol.BUILD_NO = 1
               AND gol.LINE_NO = 1
               AND goh.OFFER_NO=gob.OFFER_NO
               AND gob.BUILD_NO = 1
               AND goh.OFFER_NO = gorc.OFFER_NO
               AND gct.CONTACT_ID = gorc.CONTACT_ID
               AND ga.CUSTOMER_ID = gc.CUSTOMER_ID
               AND ga.PRIMARY = 'Y'
               AND goh.LEAD_SALESPERSON=gsp.SALESPERSON_ID
               AND goh.OFFER_NO = ship.OFFER_NO
               AND ship.RELATION_TYPE = 'SHIP'
               AND ga1.ADDRESS_ID = ship.ADDRESS_ID
               AND ga1.CUSTOMER_ID = gc1.CUSTOMER_ID
               AND goh.OFFER_NO = bill.OFFER_NO
               AND bill.RELATION_TYPE = 'BILL'
               AND ga2.ADDRESS_ID = bill.ADDRESS_ID
               AND goh.OFFER_DATE BETWEEN APPS_JP.TZ.LOCAL_TO_DB_DATE (
                                             SYSDATE - 30
                                      AND  APPS_JP.TZ.LOCAL_TO_DB_DATE (SYSDATE)
               AND gorc.RELATION_TYPE = 'BASE'
               AND gorc.CUSTOMER_ID = gc.CUSTOMER_ID
               AND goh.SALES_CHANNEL = gc.SALES_CHANNEL
               AND gc.SALES_CHANNEL = 'SMB'
               AND goh.LEAD_SALESPERSON IN (goh.CREATED_BY, goh.LEAD_SALESPERSON)
    ORDER BY   goh.OFFER_NO;[/code]
    Please help me how to use this outer join condition.
    Thanks in advance.

    Hi,
    If you want all the rows from goh, then you don't want any conditions like  goh.OFFER_NO <> 0.
    Make all the joins to goh outer joins, and make all conditions that apply to any tables joined to goh (or to tables joined to them) part of the join condition, like this:
    FROM             APPS_JP.GEDIS_OFFER_HEADER     goh
    LEFT OUTER JOIN  APPS_JP.GEDIS_ORDER_BUILDS     gob  ON   gob.OFFER_NO = goh.OFFER_NO
                                                         AND  gob.BUILD_NO = 1
    LEFT OUTER JOIN  APPS_JP.GEDIS_ORDER_LINES      gol  ON   gol.OFFER_NO = goh.OFFER_NO
                                                         AND  gol.BUILD_NO = 1
                                                         AND  gol.LINE_NO  = 1
    LEFT OUTER JOIN  APPS_JP.GEDIS_OFFER_RELATED_CUSTOMER
                                                    gorc ...
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
    Simplify the problem as much as possible.  For example, do you really need all those tables to show what the problem is?  Of course, you need them in tyour real query, but if you understand a solution that only involves 4 or 5 tables, you'll know how to apply it to any number of tables.
    Explain, using specific examples, how you get those results from that data.Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
    See the forum FAQ https://forums.oracle.com/message/9362002#9362002

  • Sample code and senarios to use outer join?

    We know the ABAP4 syntax for inner join, but never tried outer join and we even don't know if there is any outer join syntax in ABAP4 or not.  Would be very appreciated if some ABAP expert here let us know if there is any outer join and list the difference between inner join and outer join with detailed senarios or when we would use outer join or when to use inner join?  Also give a sample code on the outer join if there is any in ABAP?
    Thanks and we will give you reward points!

    Hye..
    Left outer join between table 1 and table 2 where column D in both tables set the join condition:
    Table 1                      Table 2
    A
    B
    C
    D
    D
    E
    F
    G
    H
    a1
    b1
    c1
    1
    1
    e1
    f1
    g1
    h1
    a2
    b2
    c2
    1
    3
    e2
    f2
    g2
    h2
    a3
    b3
    c3
    2
    4
    e3
    f3
    g3
    h3
    a4
    b4
    c4
    3
    |--|||--|
        Left Outer Join
        |--||||||||--|
        | A  | B  | C  | D  | D  | E  | F  | G  | H  |
        |--||||||||--|
        | a1 | b1 | c1 | 1  | 1  | e1 | f1 | g1 | h1 |
        | a2 | b2 | c2 | 1  | 1  | e1 | f1 | g1 | h1 |
        | a3 | b3 | c3 | 2  |NULL|NULL|NULL|NULL|NULL|
        | a4 | b4 | c4 | 3  | 3  | e2 | f2 | g2 | h2 |
        |--||||||||--|
    Example
    Output a list of all custimers with their bookings for October 15th, 2001:
    DATA: CUSTOMER TYPE SCUSTOM,
          BOOKING  TYPE SBOOK.
    SELECT SCUSTOMNAME SCUSTOMPOSTCODE SCUSTOM~CITY
           SBOOKFLDATE SBOOKCARRID SBOOKCONNID SBOOKBOOKID
           INTO (CUSTOMER-NAME, CUSTOMER-POSTCODE, CUSTOMER-CITY,
                 BOOKING-FLDATE, BOOKING-CARRID, BOOKING-CONNID,
                 BOOKING-BOOKID)
           FROM SCUSTOM LEFT OUTER JOIN SBOOK
             ON SCUSTOMID = SBOOKCUSTOMID AND
                SBOOK~FLDATE = '20011015'
           ORDER BY SCUSTOMNAME SBOOKFLDATE.
      WRITE: / CUSTOMER-NAME, CUSTOMER-POSTCODE, CUSTOMER-CITY,
               BOOKING-FLDATE, BOOKING-CARRID, BOOKING-CONNID,
               BOOKING-BOOKID.
    ENDSELECT.
    Reward if helpful.
    Thanks.
    Imran.

  • Dont want to use outer joins

    Hi Guys,
    I have some data in lookup tables and in the main tables the foreign keys are nullable. For this I have to use outer join query. But as it matters on performance because I am using 100's of tables like this and its making the query really slow. Is there any other way to get rid of outer join and get the same result??
    Thanks in advance.
    Ghulam Mustafa Butt

    First, why "avoid outer joins at all costs"? If you need the functionality of an outer join, using an outer join is the best option.
    Second, I don't see where 161992's code does anything other than an inner join in a slighly more convoluted form.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • How to use outer join in Corelated Update?

    Hi,
    I am using outer join in correlated update comand. But it is not updating the line which is not retrived from the query. Below is the example.
    Update model_table a
    Set a.model = (Select b.model_name from parts_table b
                        where b.model_id (+) = a.model_id)Check the above query and please let me know whether can user like this or not?
    Thanks

    Updating the values you want through subqueries is tricky. The correlated update should perform okay if the join columns are indexed but updating the correct rows may take some thought.
    You might need to add a WHERE clause to the update to use the subquery to only update the rows when the subquery return value is not null - if this is what you want. Something like
    Update model_table a
    Set a.model = (Select b.model_name from parts_table b
                        where b.model_id = a.model_id)
    where exists (Select b.model_name from parts_table b
                        where b.model_id = a.model_id)Edited by: riedelme on Jan 4, 2010 5:59 AM

  • How to use outer join on 3 tables

    how to use outer join on 3 tables
    say tables are mkpf,lips and vbrp
    mkpf-xblnr = lips-vbeln
    lips-vbeln  = vbrp-vgbel

    refer following querry
        select a~bukrs
               a~anln1
               a~ord42
               a~ord43
               b~afabe
               b~ndabj
               b~kaafa
               b~aafag
               c~kostl
               d~afasl
               d~ndjar
               d~ndper
        into corresponding fields of table gt_master
        from ( ( anla as a inner join anlc as b
        on abukrs = bbukrs
        and aanln1 = banln1
        and aanln2 = banln2 )
        inner join anlz as c
        on  abukrs = cbukrs
        and aanln1 = canln1
        and aanln2 = canln2 )
        inner join anlb as d
        on  abukrs = dbukrs
        and aanln1 = danln1
        and aanln2 = danln2
        where a~bukrs in s_comp.

  • How can I make GRID view the default view? The icons for view that used to be located in the upper right top of the page near the 'search library' are gone.

    How can I make GRID view the default view? The icons for view that used to be located in the upper right top of the page near the 'search library' are gone.

    99jon wrote:
    Perhaps it’s a design feature to speed up the Organizer launch.
    I am sure it is.
    - The normal use of the Organizer is not the folder view, it's the thumbnail view with an organization based on categories and folder. That way you should forget completely where your pictures are stored. Anyway, the folder view in the Explorer is not a map of the location of the different bits of your file, it's only a logical representation. That's easy to see when you are doing a defragmentation.
    - The folder view is useful even for those using normally the thumbnail view, but that is only for rare cases when you must change the folder organization, for instance moving files to another drive. The folder view is here to prevent you from changing things from the explorer and outside of the Organizer.
    - The new folder list view, which you find 'funny' is there to help better organizing using tags. Its huge advantage is that such a view is created extremely quickly by extracting the last subfolder in the media table : it's the way the database sees the folders, based on its own content,  totally ignoring the complex folder organization of your disk with media files or any unrelated other kind of data. You should use it in many cases, the main purpose being assigning tags when you have assigned descriptive folder names. I had suggested such a solution to prevent the long standing bugs in the folder view of previous versions.
    So yes, the purpose is:
    - to speed up switching modes
    - to help folder organization fans to migrate to tags organization
    - to hopefully get rid of the old folder organization bugs

  • Issues with using Outer join in Data Template

    Hi all,
    this is my data in two tables .
    Table Ronny1
    colA colB
    1 u
    2 v
    3 x
    Table Ronny2
    colC colD
    1 q
    2 r
    This is my data template
    <dataTemplate name="MGF" dataSourceRef="Source1">
         <dataQuery>
              <sqlStatement name="Q1" dataSourceRef="Source1">
                   <![CDATA[select C, D  from Ronny2]]>
              </sqlStatement>
              <sqlStatement name="Q2" dataSourceRef="Source2">
                   <![CDATA[select A , B from lokesh1 where A = :C]]>
              </sqlStatement>
         </dataQuery>
         <dataStructure>
              <group name="G1" source="Q1">
                   <group name="G2" source="Q2">
                        <element name="A" value="A"/>
                        <element name="B" value="B"/>
                   </group>
              </group>
         </dataStructure>
    </dataTemplate>
    Now this would give me result as
    A B
    1 u
    2 v
    however my requirement is this
    A B
    1 u
    2 v
    3 x
    that is, i want to display all the rows of table Ronny1 and matching rows from table Ronny2. I tried modifiying my second sql as
    <![CDATA[select A , B from lokesh1 where A = :C (+)]]> ( using a outer join)
    but this does give me correct data and comes back with the cartesion product.
    Can anyone please answer this for me that how can we use the outer join in data templaes.
    Thanks
    Ronny

    hey vetsrini,
    sorry for the confusion here,
    actually i want to display all the rows from table Ronny1 and i am also pulling in the matching rows from table Ronny2 and my data structure looks as ( pulling in column D from table Ronny2)
    <dataStructure>
    <group name="G1" source="Q1">
    <group name="G2" source="Q2">
    <element name="A" value="A"/>
    <element name="B" value="B"/>
    <element name="D" value="D"/>
    </group>
    </group>
    </dataStructure>
    and this is what i want the output to be
    A B D
    1 u q
    2 v r
    3 x
    Hence the row where A <> C the data in the D column will be null, same as in the case of outer join.
    any suggestions
    Thx
    Ronny

  • Internal Assertion Error while using outer join

    Hi-
    Has anyone experienced this error before: State: HY000. Code: 397397248. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 46036] Internal Assertion: Condition !pConjunct->IsAndCond(), file server/Query/Optimizer/Request/Src/SQORToCNF.cpp, line 46. (HY000)
    It happened after I changed the join in logical layer from inner join into left outer join from Fact Tab1 to Fact Tab2, This needs to be changed for cases:
    Fact Tab1 contains:
    Period|Currency|FX Rate
    Mar-09|USD|1
    Apr-09|USD|1.1
    Fact Tab2 contains:
    Period|Currency|Product|Profit
    Mar-09|USD|Metal Abs|1000
    Mar-09|USD|Grey Wood|2000
    Expected Result:
    Period|Currency|Product|Profit|FX Rate
    Mar-09|USD|Metal Abs|1000|1
    Mar-09|USD|Grey Wood|2000|1
    Apr-09|USD|(NULL)|(NULL)|1.1
    But, it shows the error as above (have changed the SERVER_THREAD_STACK_SIZE to 512 KB too but no luck, any idea?
    Thanks,
    Will

    Hey Will,
    Recently I've seen OBIEE generate some bad queries on an Oracle Database. I had setup a few time series measures and when I added more than three into a report, I got a table not found error. It turned out that it was a combination of the query getting very complex and the way it was using ANSI SQL Left Outer Join operator. I'm wondering if your situation is similar.
    Can you try the following?
    1. Log into the RPD and for your user, set the logging level to 7 (Manage->Security then find your user).
    2. Clear all the caches (BI Server=Manage->Cache delete them all, Presentation Server=Settings->Manage Sessions then close all cursors)
    3. Run the report for a date range that works fine
    4. Run the report for a date range that causes the error.
    5. Look at the physical SQL generated in the log files (Settings->Manage Sessions)
    Compare the two queries and see if anything stands out. In fact try to execute both in SQL Developer or Toad and see if you get any errors. If you can, post the physical SQL and I might be able to notice something.
    Just to confirm, you're using OCI to connect to an Oracle source right?
    In my situation, I fixed it by disabling the LEFT OUTER JOIN syntax on the database. We might be able to get you to do something similar to fix your problem.
    Thanks!
    -Joe

  • SQL for views with constraints

    We use a product that requires us to have pk's on all of our views. So when I generate the SQL using DBMS_METADATA or using SQL Developer we have to keep the original scripts so that we can manually insert the constraint definition into the generated script.
    I noted that while browsing the SQL tab for each view I can see the constraint in the view definition. So where is this tab generating it's SQL from? It's not in the text of the view, and dbms_metadata does not seem to do it.
    It would be useful for me to be able to generate them with the constraint in the text already as this process that we do now is cumbersome.
    Can anyone tell me where/how I can do that?
    Cheers,
    Henri

    OK, here is little test:
    alter view emp_sal
    add constraint emp_sal_uk unique (ename) DISABLE NOVALIDATE ;
    After that command the view definition is
    CREATE OR REPLACE FORCE VIEW "SCOTT"."EMP_SAL" ("EMPNO", "ENAME", "SAL",
         UNIQUE ("EMPNO") RELY DISABLE,
         CONSTRAINT "ID_PK" PRIMARY KEY ("EMPNO") RELY DISABLE,
         CONSTRAINT "EMP_SAL_UK" UNIQUE ("ENAME") DISABLE) AS
    SELECT empno, ename, sal FROM emp;
    so that the constraint becomes effectively inline. It is displayed with
    select dbms_metadata.GET_DDL('VIEW', 'EMP_SAL') from dual;

  • View definition using Temporary table

    I am trying to create a view using a global temporary table Odyssey.HMSg_ReportGeneral :
    create or replace view Odyssey.av_hms_TmpTbl_rpt_ClsGndr4dtsSub1
    as select nvl(p.Gender,'Either') gender, bldg.Building Bldg, bldg.Site_Name Parent1, bldg.Room_Name name,
    bldg.Building_Name Parent2, bldg.facility_sk_fk facility_sk, nvl(pc.Class,'Unspecified') Class, p.patron_sk,
    count(t1.Patron_SK_FK) NumOccupants, nvl(pc.listing_order,0) ListOrd
    from Odyssey.HMSg_ReportGeneral g,Odyssey.av_hms_rpt_ThisAssignmentLevel fa3
    join Odyssey.av_hms_rpt_FacilityStructure bldg on(bldg.facility_sk_fk = fa3.facility_sk_FK and
    (bldg.effectivedate is null or(bldg.effectivedate <= g.Date2 and(bldg.enddate is null or
    bldg.enddate >= g.Date2)))) left outer join Odyssey.av_hms_rpt_NumOccupantsNoCount t1
    on(t1.Facility_SK = bldg.facility_sk_fk and
    (t1.elementstart is null or(t1.elementstart <= g.date2 and(t1.elementend is null or
    t1.elementend >= g.date2)))) left outer join Odyssey.csdp_patron p
    on(p.patron_SK = t1.patron_SK_FK) left outer join Odyssey.av_hms_rpt_PatronClass pc
    on(pc.Patron_SK_FK = t1.Patron_SK_FK and(pc.effectivedate is null or (pc.effectivedate <=
    g.date2 and(pc.enddate is null or pc.enddate >= g.date2))))
    where fa3.effectivedate is null or(fa3.effectivedate <= g.Date1 and(fa3.enddate is null or fa3.enddate >= g.Date1))
    group by bldg.Site_Name, bldg.Building_Name,bldg.Building, pc.Class, pc.listing_order, p.patron_sk, p.Gender,
    bldg.facility_sk_fk, bldg.Room_Name
    I get an error :
    ORA-00904: "G"."DATE2": invalid identifier
    If I removed all references to the global temporary table,
    the view compiles fine - references to any of the columns in the temporary table give the ORA-00904.
    Any suggestions ?
    (FYI we are converting a database from Sybase to Oracle and have almost 20 views like this)
    Thanks for the help

    Hi
    After some test following I got following code to compile.
    create or replace view Odyssey.hms_TmpTbl_rpt_ClsGndr4dtsSub1 as
    select nvl(p.Gender,'Either') gender,
            bldg.Building Bldg,
            bldg.Site_Name Parent1,
            bldg.Room_Name name,
            bldg.Building_Name Parent2,
            bldg.facility_sk_fk facility_sk,
            nvl(pc.Class,'Unspecified') Class,
            p.patron_sk,
            count(t1.Patron_SK_FK) NumOccupants,
            nvl(pc.listing_order,0) ListOrd
    from
            Odyssey.HMSg_ReportGeneral g
            join
            Odyssey.av_hms_rpt_ThisAssignmentLevel fa3 on
                    fa3.effectivedate is null
                or  (
                        fa3.effectivedate <= g.Date1
                    and     (   fa3.enddate is null
                        or  fa3.enddate >= g.Date1
            join
            Odyssey.av_hms_rpt_FacilityStructure bldg on
                (   bldg.facility_sk_fk = fa3.facility_sk_FK
                and     (   bldg.effectivedate is null
                    or     (   bldg.effectivedate <= g.Date2
                        and (   bldg.enddate is null
                            or  bldg.enddate >= g.Date2
            left outer join
            Odyssey.av_hms_rpt_NumOccupantsNoCount t1 on
                (   t1.Facility_SK = bldg.facility_sk_fk
                and (   t1.elementstart is null
                    or  (   t1.elementstart <= g.date2
                        and (   t1.elementend is null
                            or  t1.elementend >= g.date2
            left outer join
            Odyssey.csdp_patron p on
                (   p.patron_SK = t1.patron_SK_FK
            left outer join
            Odyssey.av_hms_rpt_PatronClass pc on
                (   pc.Patron_SK_FK = t1.Patron_SK_FK
                and (   pc.effectivedate is null
                    or  (   pc.effectivedate <= g.date2
                        and (   pc.enddate is null
                            or  pc.enddate >= g.date2
    group by
            bldg.Site_Name,
            bldg.Building_Name,
            bldg.Building,
            pc.Class,
            pc.listing_order,
            p.patron_sk,
            p.Gender,
            bldg.facility_sk_fk,
            bldg.Room_NameI think you can't mix old and new type of writing
    you have to do the join
    between Odyssey.HMSg_ReportGeneral
    and Odyssey.av_hms_rpt_ThisAssignmentLevel
    to have Odyssey.HMSg_ReportGeneral in the join statement later on.

  • How do I use OUTER JOIN to email different message than the default

    I have a devotional that goes out daily from a MOBILE table containing:
    mob_id
    calendardate
    title
    scripture
    body
    The same devotional goes out to 3 different churches.
    I have a second TABLE called EDITED that holds an edited version of the daily devotional, containing:
    edit_id
    calendardate
    etitle
    escripture
    ebody
    The query should look in the edited table for a devotional first to see if it matches the current date then send it out. Otherwise it sends out the default devotional  that corresponds with the current date.
    I would like to send out in replacement of the default devotional  to the church that edited the devotional.
    I am using the following outer Join but it doesn’t work. It sends the same devotional to everybody.
    <cfoutput>
    <cfloop query="getClients">
    <!--- determine if there is an edited version of the devotional available for this day --->
    <cfquery name="getDevotional" datasource="#application.dsn#">
    SELECT mobile.mob_id, mobile.display_date, mobile.title, mobile.body, mobile.scripture,edited.edit_id,edited.contact_id,edited.etitle,edited.escripture,edited. ebody
    FROM mobile
    left outer join edited ON mobile.display_date = edited.display_date
    where mobile.display_date = <cfqueryparam value ="#dateformat(now(), "YYYY-MM-DD")#" cfsqltype="cf_sql_date">
    </cfquery>
    What am I missing?

    Yes the getClients grabs all information pertaining to the client and their layout information.
    <cfquery name="getClients" datasource="#application.dsn#">
    select *
    from (subscriber INNER JOIN contacts ON subscriber.contact_id = contacts.contact_id)INNER JOIN layout ON contacts.contact_id = layout.contact_id
    where subscriber.timezone = 3
    </cfquery>
    Below is the logic I used to determine which version to use:
    <cfif getDevotional.edit_id NEQ "">#GetDevotional.etitle#<cfelse>#GetDevotional.title#</cfif>

  • How to use outer join to display the results

    I want to develop a report in which the column sequence will be as follows:
    1)Item_code
    2)Item_name
    3)Stock
    4)Pending
    5)Re-order Level
    6)Item_reorder_qty
    I had written the query, but the problem is all the products does not get displayed. The products are more than 700. But after running the query, only 364 gets displayed.
    How i can make use of outer join in the following statements :
    AND ITEM_CODE = LCS_ITEM_CODE
    AND ITEM_CODE = PI_ITEM_CODE
    AND LCS_ITEM_CODE = PI_ITEM_CODE
    in the below given query to solve this.
    SELECT
    ITEM_CODE,
    ITEM_NAME,
    ((LCS_STK_QTY_BU + LCS_RCVD_QTY_BU - LCS_ISSD_QTY_BU- LCS_REJECT_QTY_BU)/IU_MAX_LOOSE_1)STK ,
    SUM(TO_NUMBER(PI_QTY||'.'||PI_QTY_LS) - (PI_GI_QTY_BU/IU_CONV_FACTOR/IU_MAX_LOOSE_1))PNDG,
    ITEM_RORD_LVL,
    ITEM_RORD_QTY
    FROM
    OM_ITEM,
    OM_ITEM_UOM,
    OT_PO_HEAD,
    OT_PO_ITEM,
    OS_LOCN_CURR_STK
    WHERE (ITEM_UOM_CODE = IU_UOM_CODE AND ITEM_CODE = IU_ITEM_CODE)
    AND ITEM_CODE = LCS_ITEM_CODE
    AND ITEM_CODE = PI_ITEM_CODE
    AND LCS_ITEM_CODE = PI_ITEM_CODE
    AND LCS_LOCN_CODE ='RM'
    AND PI_PH_SYS_ID = PH_SYS_ID
    GROUP BY ITEM_CODE,ITEM_NAME,LCS_STK_QTY_BU,LCS_RCVD_QTY_BU,LCS_ISSD_QTY_BU,LCS_REJECT_QTY_BU,IU_MAX_LOOSE_1,ITEM_RORD_LVL,ITEM_RORD_QTY
    ORDER BY ITEM_CODE ASC
    Yogesh

    As you have no table aliases I can't tell what columns relate to which tables on your join conditions.
    Can you not just put (+) next to the outer joined columns you require on the where clause? Or perhaps consider using ANSI syntax for the joins such as <tableA> LEFT OUTER JOIN <tableB> ON (<join conditions>)

  • How to use outer join in Target table

    hi all:
    how to use outer joing and trunc in target table?

    Good morning,
    Can you be more specific?
    What do you want to join, what needs to be truncated, what's the Loading Type of your target table-object, etc.
    In general the following applies.
    An outer join is specified on the JOIN operator, under Operator Properties you can specify the Join Condition, for example:
    tab1.uk_col1 = tab2.uk_col1(+)
    and
    tab1.uk_col2 = tab2.uk_col2(+)Truncating a table in a mapping can only be done in combination with inserting the dataset, setting the loading type of a table to TRUNCATE/INSERT.
    Apart from that there is a predefined OWB transformation called WB_TRUNCATE_TABLE, this can also be used to truncate a table.
    Cheers, Patrick

Maybe you are looking for

  • Online test questions... plz  provide answers

    How can we copy a standard table to make our own z_table? By using the copy option in SE11. By using include structure command. By using Append structure command. By Copying the entire structure of the standard table in our new table. In reporting te

  • How can i back up my itunes library onto an external hard drive?

    I can seem to figure out how to back up my Itunes library onto my external hard drive. Any advise?

  • Multiple alerts for the same Message ID

    Hi I have configured outbound ftp adapter. I have configured alerts inorder to capture any error in the adapter engine. Now,alert is triggered showing an error in the ftp adapter ( say incorrect ftp details). But i get multiple alerts for the same me

  • Sales order not created using BAPI_SALESORDER_CREATEFROMDAT2

    HI, I have used the bapi BAPI_SALESORDER_CREATEFROMDAT2 to create sales order. I have passed the parameters, doc_type, sales_org, distr_chan, division, partn_role, part_numb and material. It displays back the message as sales_header_in createds, sale

  • Error in Essbase Dim Build

    Hi, I am getting error "\\Invalid Rules File, which was created using a newer version" in the error file while trying to load dimensions into my outline .