How to use Inner join of table as Source in Merge statement in SQL

Hi All,
    I am trying to make source as multiple tables output using Join while coding there is no any syntax error but when i am executing this statement is giving following error
Following is the query 
Merge Into EmpDept Target
Using (select E.Address,e.Design,e.EmailId,e.EmpId,e.Ename,e.ManagerId, e.Salary,D.DeptId,D.DeptName,D.Location from Employee E Inner join Dept D on E.DeptId=D.DeptId )As Source (Address,Design,EmailId,EmpId,EName,ManagerId,Salary,DeptId,DeptName,Location)
On Source.EmpId=Target.EmpId
when not matched then
Insert (Target.Address,Target.Design,Target.EmailId,Target.EmpId,Target.Ename,Target.ManagerId, Target.Salary,Target.DeptId,Target.DeptName,Target.Location)
values
(Address,Design,EmailId,EmpId,EName,ManagerId, Salary,DeptId,DeptName,Location)
When matched then 
Update set Target.Address = Source.Address ,Target.Design = Source.Design,Target.EmailId      = Source.EmailId     ,Target.Ename       = Source.Ename      ,Target.ManagerId = Source.ManagerId , Target.Salary        = Source.Salary       ,Target.DeptId      = Source.DeptId      ,Target.DeptName = Source.DeptName ,Target.Location    = Source.Location;
This is error while executing the above merge statement 
The insert column list used in the MERGE statement cannot contain multi-part identifiers. Use single part identifiers instead.
Please suggest me where i am wrong.. 
Niraj Sevalkar

MERGE INTO EmpDept Target
Using (SELECT E.Address,
e.Design,
e.EmailId,
e.EmpId,
e.Ename,
e.ManagerId,
e.Salary,
D.DeptId,
D.DeptName,
D.Location
FROM Employee E
INNER JOIN Dept D
ON E.DeptId = D.DeptId) AS Source (Address, Design, EmailId, EmpId, EName, ManagerId, Salary, DeptId, DeptName, Location)
ON Source.EmpId = Target.EmpId
WHEN NOT matched THEN
INSERT (Address,
Design,
EmailId,
EmpId,
Ename,
ManagerId,
Salary,
DeptId,
DeptName,
Location)
VALUES (Address,
Design,
EmailId,
EmpId,
EName,
ManagerId,
Salary,
DeptId,
DeptName,
Location)
WHEN matched THEN
UPDATE SET Address = Source.Address,
Design = Source.Design,
EmailId = Source.EmailId,
Ename = Source.Ename,
ManagerId = Source.ManagerId,
Salary = Source.Salary,
DeptId = Source.DeptId,
DeptName = Source.DeptName,
Location = Source.Location;

Similar Messages

  • How to use INNER JOIN in such case

    when i program as below[CASE1]. the code is able to active.
    CASE1:
    ==========================
    DATA: WK_BUKRS LIKE T001-BUKRS,
          WK_BUTXT LIKE T001-BUTXT,
          WK_TABLE(4) TYPE C VALUE 'T001'.
    START-OF-SELECTION.
      WK_BUKRS = 'DECN'.
      PERFORM GET_BUTXT USING WK_BUKRS WK_TABLE
                     CHANGING WK_BUTXT.
      WRITE: WK_BUTXT.
      FORM GET_BUTXT USING I_BUKRS LIKE T001-BUKRS
                           I_TABLE
                  CHANGING O_BUTXT LIKE T001-BUTXT.
        SELECT SINGLE BUTXT
                 INTO O_BUTXT
                 FROM (I_TABLE)
                WHERE BUKRS = I_BUKRS.
      ENDFORM.                   
    ===========================
    but when I need to INNER JOIN another table [CASE2]
    CASE2:
    =======================
    DATA: WK_BUKRS LIKE T001-BUKRS,
          WK_BUTXT LIKE T001-BUTXT,
          WK_TABLE(4) TYPE C VALUE 'T001'.
    START-OF-SELECTION.
      WK_BUKRS = 'DECN'.
      PERFORM GET_BUTXT USING WK_BUKRS WK_TABLE
                     CHANGING WK_BUTXT.
      WRITE: WK_BUTXT.
      FORM GET_BUTXT USING I_BUKRS LIKE T001-BUKRS
                           I_TABLE
                    CHANGING O_BUTXT LIKE T001-BUTXT.
        SELECT SINGLE BUTXT
                 INTO O_BUTXT
                 FROM (I_TABLE) AS G INNER JOIN BKPF AS H
                   ON GBUKRS = HBUKRS
                WHERE G~BUKRS = I_BUKRS.
      ENDFORM.          
    =================================
    Syntax error:
    Wrong expression "INNER" in FROM clause. WHERE condition.
    Can anybody help me to solve the problem.
    My requirement is to use INNER JOIN with variable table

    hi slam,
    chk this sample code.
    hi,
    table emp
    empno name
    a sasi
    b xxx
    c yyy
    table sal
    empno salary
    a 1000
    b 2000
    Inner join
    select eempno ename
    s~sal
    into table int_table
    from emp as e
    inner join sal as s
    on
    eempno = sempno.
    if you made inner join between table a and b by emp no
    the selection retrives only if the condition satisfy the output will be
    a sasi 1000
    b xxx 2000
    rgds
    anver
    if hlped mark points
    Message was edited by: Anversha s

  • How to use Inner Join for these 4 table's

    Hi Guys,
                  My Requirement is i have to get the data into the final Internal table whose structure is like this (BWKEY   type  MBEW-BWKEY,
            MATNR   type  MBEW-MATNR,
            MAKTX   type  MAKT-MAKTX,
            BWTTY   type  MBEW-BWTTY,
            BWTAR   type  MBEW-BWTAR,
            MEINS   type  MARA-MEINS,
            BKLAS   type  MBEW-BKLAS,
            VPRSV   type  MBEW-VPRSV,
            STPRS   type  MBEW-STPRS,
            PEINH   type  MBEW-PEINH,
            CRCY(3)    type  c,
            LBKUM   type  MBEW-LBKUM,
            SALK3   type  MBEW-SALK3,
            LAEPR   type  MBEW-LAEPR,
            J_3ADEFSI   type  MARC-J_3ADEFSI,
            J_4kDEFSC   type  MARC-J_4kDEFSC,
            SCLAS   type  MARA-/AFS/SCLAS,
            EKALR   type  MBEW-EKALR,
            HKMAT   type  MBEW-HKMAT,
            HRKFT   type  MBEW-HRKFT,
            KOSGR   type  MBEW-KOSGR,
            PRCTR   type  MARC-PRCTR,
            MMSTA   type  MARC-MMSTA,
            SOBSK   type  MARC-SOBSK,
            PPRDL   type  MBEW-PPRDL,
            LPLPR   type  MBEW-LPLPR,
            PPRDZ   type  MBEW-PPRDZ,
            ZPLPR   type  MBEW-ZPLPR)
                  from 4 table's MBEW , MARA MAKT and MARC.
         Can anybody provide the logci for this based on the below requirement
    "Go to table MBEW with material number, plant and valuation type; fetch the information laid out in output format. There are some fields which need to come from tables MARC, MARA and MAKT. The common criterion is material number across these tables.
    MBEW-MATNR = MARC-MATNR
    MBEW-MATNR = MARA-MATNR
    MBEW-MATNR = MAKT-MATNR
    Thanks,
    Gopi.

    Hello Gopi,
    I did not have system now and just written in notepad..
    types : begin of ty_mbew ,
    MATNR type MBEW-MATNR,
    BWTTY type MBEW-BWTTY,
    BWTAR type MBEW-BWTAR,
    MEINS type MARA-MEINS,
    BKLAS type MBEW-BKLAS,
    VPRSV type MBEW-VPRSV,
    STPRS type MBEW-STPRS,
    PEINH type MBEW-PEINH,
    CRCY(3) type c, " What is this field ,i did not include in join
    LBKUM type MBEW-LBKUM,
    SALK3 type MBEW-SALK3,
    LAEPR type MBEW-LAEPR,
    J_3ADEFSI type MARC-J_3ADEFSI,
    J_4kDEFSC type MARC-J_4kDEFSC,
    SCLAS type MARA-/AFS/SCLAS,
    EKALR type MBEW-EKALR,
    HKMAT type MBEW-HKMAT,
    HRKFT type MBEW-HRKFT,
    KOSGR type MBEW-KOSGR,
    PRCTR type MARC-PRCTR,
    MMSTA type MARC-MMSTA,
    SOBSK type MARC-SOBSK,
    PPRDL type MBEW-PPRDL,
    LPLPR type MBEW-LPLPR,
    PPRDZ type MBEW-PPRDZ,
    ZPLPR type MBEW-ZPLPR,
    end of ty_mbew.
    types : begin of ty_makt ,
    matnr type makt-maktx,
    MAKTX type MAKT-MAKTX,
    end of ty_makt.
    types : begin of ty_final ,
    MATNR type MBEW-MATNR,
    MAKTX type MAKT-MAKTX,
    BWTTY type MBEW-BWTTY,
    BWTAR type MBEW-BWTAR,
    MEINS type MARA-MEINS,
    BKLAS type MBEW-BKLAS,
    VPRSV type MBEW-VPRSV,
    STPRS type MBEW-STPRS,
    PEINH type MBEW-PEINH,
    CRCY(3) type c,
    LBKUM type MBEW-LBKUM,
    SALK3 type MBEW-SALK3,
    LAEPR type MBEW-LAEPR,
    J_3ADEFSI type MARC-J_3ADEFSI,
    J_4kDEFSC type MARC-J_4kDEFSC,
    SCLAS type MARA-/AFS/SCLAS,
    EKALR type MBEW-EKALR,
    HKMAT type MBEW-HKMAT,
    HRKFT type MBEW-HRKFT,
    KOSGR type MBEW-KOSGR,
    PRCTR type MARC-PRCTR,
    MMSTA type MARC-MMSTA,
    SOBSK type MARC-SOBSK,
    PPRDL type MBEW-PPRDL,
    LPLPR type MBEW-LPLPR,
    PPRDZ type MBEW-PPRDZ,
    ZPLPR type MBEW-ZPLPR,
    end of ty_final.
    Internal tables
    data :i_mbew type standard table of ty_mbew,
    i_makt type standard table of ty_makt,
    i_final type standard table of ty_final.
    Work Areas
    data : wa_mbew like line of i_mbew,
    wa_makt like line of i_makt,
    wa_final like line of i_final.
    start-of-selection.
    get the data from MBEW,MARA,MARC Table
    select aMATNR aBWTTY
           aBWTAR bMEINS
           aBKLAS aVPRSV
           aSTPRS aPEINH
    *CRCY(3) type c,
    aLBKUM aSALK3 a~LAEPR
    c~J_3ADEFSI type MARC-J_3ADEFSI,
    c~J_4kDEFSC type MARC-J_4kDEFSC,
    b~SCLAS type MARA-/AFS/SCLAS,
    aEKALR aHKMAT
    aHRKFT aKOSGR
    cPRCTR cMMSTA
    cSOBSK aPPRDL
    aLPLPR aPPRDZ
    a~ZPLPR into corresponding fields of table i_mbew
            from mbew as a inner join mara as b on bmatnr = amatnr
            inner join marc as c on cmatnr = amatnr.
    if sy-subrc eq 0.
    select matnr maktx from makt into table i_makt
                 for all entries in i_mbew
                 where matnr = i_mbew-matnr
                 and   spras = sy-langu.
    endif.
    loop at i_mbew into wa_mbew.
    read the data from MAKT Table
    read table i_makt into wa_makt with key matnr = wa_mbew-matnr.
    if sy-subrc eq 0.
    move-corresponding wa_mbew to wa_final.
    move wa_makt-maktx to wa_final-maktx.
    append wa_final to i_final.
    endif.
    endloop.
    Thanks
    Seshu

  • How to use inner joins for 4 0r 5 tables

    Hai Experts,
    plz check my code, n plz help to inner join all the tables
    TYPES : BEGIN OF ITAB,
           EBELN TYPE EKKO-EBELN,            "P.O.NUMBER
           AEDAT TYPE EKKO-AEDAT,            "DATE
           BPRME TYPE EKPO-BPRME,            "UNIT PRICE
           MENGE TYPE EKPO-MENGE,            "Purchase order quantity
           WERKS TYPE EKPO-WERKS,            "PLANT
           BRTWR TYPE EKPO-BRTWR,            "Gross order value in PO
           STRAS TYPE LFA1-STRAS,            "House number and street
           LIFNR TYPE LFA1-LIFNR,            "VENDOR NO
           NAME1 TYPE LFA1-NAME1,            "V NAME
           ORT01 TYPE LFA1-ORT01,            "CITY
           LAND1 TYPE LFA1-LAND1,            "LAND
           PSTLZ TYPE LFA1-PSTLZ,             "POSTAL CODE
           MAKTX TYPE MAKT-MAKTX,            "DESCRIPTION
    END OF ITAB.
    <b>and i got stucked here:</b>
    <u></u>
    SELECT EKKO~EBELN
             EKKO~AEDAT
             EKPO~BPRME
             EKPO~MENGE
             EKPO~WERKS
             EKPO~BRTWR
             LFA1~LIFNR
             LFA1~STRAS
             LFA1~NAME1
             LFA1~ORT01
             LFA1~LAND1
             LFA1~PSTLZ
             MAKT~MAKTX
             INTO TABLE ITAB
             FROM EKKO
             INNER JOIN EKPO LFA1 T001W MAKT
             ON EKKOEBELN = EKPOEBELN
                EKKO~EBELN
             WHERE EKKO~EBELN IN S_EBELN.

    hi Rajesh,
    you have to join the tables one by one:
    SELECT ekko~ebeln
                 ekko~aedat
                 ekpo~bprme
                 ekpo~menge
                 ekpo~werks
                 ekpo~brtwr
                 lfa1~lifnr
                 lfa1~stras
                 lfa1~name1
                 lfa1~ort01
                 lfa1~land1
                 lfa1~pstlz
                 makt~maktx
    INTO TABLE itab
    FROM ekko AS ekko
    INNER JOIN ekpo AS ekpo
    ON ekkoebeln EQ ekpoebeln
    INNER JOIN lfa1 AS lfa1
    ON ekkolifnr EQ lfa1lifnr
    INNER JOIN t001w AS t001w
    ON ekpowerks EQ t001wwerks
    INNER JOIN makt AS makt
    ON ekpomatnr EQ MAKTmatnr
    WHERE ekko~ebeln IN s_ebeln.
    This is the complete SELECT. BUT! The performance will be much better if you take out T001W and MAKT from the INNER JOIN. Do select on these tables in separate steps and merge the internal tables afterwards.
    hope this helps
    ec

  • 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 to 'inner join' internal table or cluster table ??

    Hi,
    when i inner join table BSEG it said is a cluster table can't be inner joined .
    i wonder how i can "inner join" bseg with a internal table such as
    data: begin of i_bseg_trans,
            bukrs like bseg-bukrs,
            gjahr like bseg-gjahr,
            belnr like bseg-belnr,
            total_runtimes like i_runtimes-total,
            already_runtimes like i_runtimes-already,
            left_runtimes like i_runtimes-left,
          end of i_bseg_trans.
    and similar things trouble me  when considering several internal tables .
    thanks for any help!!

    Hi,
    but if there's more than 2 tables,  for example
    data: begin of it_bseg occurs 0,
            bukrs like bseg-bukrs,
            else_1 type i,
         end of it_bseg.
    data: begin of t occurs 0,
            bukrs like bseg-bukrs,
          end of t.
    data: begin of r occurs 0,
            bukrs like bseg-bukrs,
            else type c,
          end of r.
    select bukrs from bkdf into table t.
    select bukrs from bkdf into corresponding fields of table it_bseg.
    select bseg~bukrs      "else_1
    from bseg      "it_bseg
      into table r
      for all entries in t
      where bseg~bukrs = t-bukrs.
          " and it_bseg-bukrs = t-bukrs.
    in the select clause i mean whether there's a method similar to the way just drop the " in my code.
    now my solution is to use another loop on it_bseg, but i think when table amount is large this is really a boring solution.

  • How  to  do inner join ,outer join, left join ,right join by using infoset

    how  to  do inner join ,outer join, left join ,right join by using infoset

    Hi
    If you want to make  join ,outer join, left join ,right join then its possible if you are using ODS or direct infoobject (In BW3.5) and if you are using BI7.0 then you also make join ,outer join, left join ,right join with Cube also.
    For making join ,outer join, left join ,right join in infosets you just select your info provider then right click on your infoarea from context menu select info set after doing this one pop-up opens here u define your infoset technical name and give either ODS object name of infoobject name.
    After doing this next screen opens in right hand side your selectes ODS or infoobject shows in graphical format .
    and left hand side it shows one menu bar here you can select another ODS or infoobject for making join ,outer join, left join ,right join .just click on ODS button in menu bar and select ODS drag your selected ODS from Left to right after doing this your selected ODS shown in right hand side window in graphical format you just now after doing this you are able to make join ,outer join, left join ,right join for this first you select field from one ods and drag a line from 1 ods to second ods after doing this one arrow is created from one ods to another ods just right click on arrow  and make join ,outer join, left join ,right join in to your ODS.
    I think its clear how we can we make join ,outer join, left join ,right join in infoset.If you have any further query then welcome.
    Assign Points...............
    Thanks and regards
    Ankit modi

  • How to use the item of table(ms access) in pl/sql

    I want to use oracle forms builer developer application with ms access database
    I don't know how to use the item of table in the pl/sql;please help me !

    MERGE INTO EmpDept Target
    Using (SELECT E.Address,
    e.Design,
    e.EmailId,
    e.EmpId,
    e.Ename,
    e.ManagerId,
    e.Salary,
    D.DeptId,
    D.DeptName,
    D.Location
    FROM Employee E
    INNER JOIN Dept D
    ON E.DeptId = D.DeptId) AS Source (Address, Design, EmailId, EmpId, EName, ManagerId, Salary, DeptId, DeptName, Location)
    ON Source.EmpId = Target.EmpId
    WHEN NOT matched THEN
    INSERT (Address,
    Design,
    EmailId,
    EmpId,
    Ename,
    ManagerId,
    Salary,
    DeptId,
    DeptName,
    Location)
    VALUES (Address,
    Design,
    EmailId,
    EmpId,
    EName,
    ManagerId,
    Salary,
    DeptId,
    DeptName,
    Location)
    WHEN matched THEN
    UPDATE SET Address = Source.Address,
    Design = Source.Design,
    EmailId = Source.EmailId,
    Ename = Source.Ename,
    ManagerId = Source.ManagerId,
    Salary = Source.Salary,
    DeptId = Source.DeptId,
    DeptName = Source.DeptName,
    Location = Source.Location;

  • Delete query using inner join

    I need to delete records from a table using inner join from other tables. See below for the table structure and records.
    CREATE TABLE STUDENT (ROLL_NO NUMBER(10),NAME VARCHAR2(100),DEPT_NO NUMBER(10),JOIN_DATE DATE);
    CREATE TABLE DEPART (DEPT_NO NUMBER(10), DEPT_NAME VARCHAR2(100));
    CREATE TABLE ACTIVE_DEPT (DEPT_NO NUMBER(10), IS_ACTIVE VARCHAR2(1));
    INSERT INTO STUDENT (ROLL_NO,NAME,DEPT_NO,JOIN_DATE) VALUES(1,'SAM',10,SYSDATE-10);
    INSERT INTO STUDENT (ROLL_NO,NAME,DEPT_NO,JOIN_DATE) VALUES(2,'ALEX',10,SYSDATE -10);
    INSERT INTO STUDENT (ROLL_NO,NAME,DEPT_NO,JOIN_DATE) VALUES(3,'FRANK',20,SYSDATE -10);
    INSERT INTO STUDENT (ROLL_NO,NAME,DEPT_NO,JOIN_DATE) VALUES(4,'WAYNE',20,SYSDATE+1);
    INSERT INTO STUDENT (ROLL_NO,NAME,DEPT_NO,JOIN_DATE) VALUES(5,'KRUL',30,SYSDATE -10);
    INSERT INTO STUDENT (ROLL_NO,NAME,DEPT_NO,JOIN_DATE) VALUES(6,'ALICE',40,SYSDATE -10);
    INSERT INTO DEPART (DEPT_NO,DEPT_NAME) VALUES (10,'DEPT1');
    INSERT INTO DEPART (DEPT_NO,DEPT_NAME) VALUES (20,'DEPT2');
    INSERT INTO DEPART (DEPT_NO,DEPT_NAME) VALUES (30,'DEPT3');
    INSERT INTO ACTIVE_DEPT (DEPT_NO,IS_ACTIVE) VALUES (10,'Y');
    INSERT INTO ACTIVE_DEPT (DEPT_NO,IS_ACTIVE) VALUES (20,'N');
    INSERT INTO ACTIVE_DEPT (DEPT_NO,IS_ACTIVE) VALUES (30,'Y');
    DELETE FROM STUDENT WHERE (STUDENT.DEPT_NO) IN (SELECT D.dept_no FROM DEPART D,ACTIVE_DEPT AD WHERE D.DEPT_NO = AD.DEPT_NO AND AD.IS_ACTIVE = 'N');The above delete query will delete two records from the STUDENT table. Now i want to include another condition say, join_date should be a past date (join_date < trunc(sysdate)).
    How to include this condition in the above delete statement. I know i can do this using a subquery but i wont prefer that option. Basically i don't have much idea about join in delete statements.
    Please help.

    Is this you need ?
    DELETE FROM student WHERE join_date < TRUNC(SYSDATE)
                                            AND student.dept_no IN (SELECT D.dept_no
                                                                      FROM depart d,active_dept ad
                                                                     WHERE d.dept_no = ad.dept_no AND ad.is_active = 'N');Only one record is deleted. -> 3,'FRANK',20,SYSDATE -10
    >
    Balaji      wrote:
    Yes. But here we are getting the dept_no from the sub query, is there a better way to achieve this without sub query?
    >
    As far I know you need to have sub query in this case.
    You can close this thread if answered. If you have any further queries please post it so that someone can help you.
    Edited by: Lokanath Giri on २० मार्च, २०१२ ५:०५ अपराह्न

  • 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

  • Select querry using inner join

    Hi Friends,
    I need to fetch data from two tables, I used inner join but I am not able to fetch the data in some fields can any one tell me what is wrong in this select querry.
    SELECT but000~partner
             but000~name_org1
             but000~name_first
             but000~name_last
             but000~bpext
          FROM but000 INNER JOIN dfkkop ON but000partner = dfkkopgpart
        INTO table lt_but000
        WHERE but000~partner IN so_part
        AND dfkkop~faedn IN so_faedn.
    Thanx in advance,
    Parvez

    hi Lutin,
    SELECT but000~partner
    but000~name_org1
    but000~name_first
    but000~name_last
    but000~bpext
    FROM but000 INNER JOIN dfkkop ON but000partner = dfkkopgpart  <------check this condition,it has to *satisfy  both table                                                                        
    INTO table lt_but000
    WHERE but000~partner IN so_part
    AND dfkkop~faedn IN so_faedn.
    Regards,
    siva
    Message was edited by:
            SivaKumar

  • How to use database look up table function in xsl mapping

    Can anybody tell me how to use database look up table function while mapping xsl between 2 nodes.
    I have an XML file coming in and depending on one of XML elements we need to decide which further path to take. But, using this XML element, we need to query database table, get metadata and accordingly take appropriate path. I have written lookup function which returns metadata value.
    Now, the issue is how do I pass the XML element valu as input to look up function? When I tried to drag it to the input node of lookup function, it throws an error like "Maximum number of parameters exceeded"
    Thanks,

    If the lookup table is always going to remain the same (e.g. a character generator or something similar) you can place the values in a 2D array constant on your diagram, with the input value as one column, the equivalent as the other. When you need to perform the lookup you use an index array to return all the values in the "input column", search it using "search 1D array" and use the resulting index number to index the other column's data. If the values may change, then it would probably be best to load an array control with your equivalent values from a file.
    P.M.
    Putnam
    Certified LabVIEW Developer
    Senior Test Engineer
    Currently using LV 6.1-LabVIEW 2012, RT8.5
    LabVIEW Champion

  • [HTML DB] How to use the existing database table?

    [HTML DB] How to use the existing database table?
    I installed Oracle 10g database in Computer A(Windows 2000), and I already create all the tables with data and the data size is about 300MB.
    In Computer B(Windows 2000), I installed HTML DB 1.6.
    How can I use /get the existing database table (in computer A) for HTML DB?
    Could anyone help me on this? I am newbie and I need some detail instructions. or Where can I find the examples.....
    Thanks

    Well I guess if you wish to retain that architecture, i.e. HTMLDB on one machine and your data on another, you will have to establish database links to access the data. Oracle documentation will describe how to achieve that.

  • How do we use Data rules/error table for source validation?

    How do we use Data rules/error table for source validation?
    We are using OWB repository 10.2.0.3.0 and OWB client 10.2.0.3.33. The Oracle version is 10 G (10.2.0.3.0). OWB is installed on Linux.
    I reviewed the posting
    Re: Using Data Rules
    Thanks for this forum.
    I want to apply data rules to source table/view and rule violated rows should go to defined error table. Here is an example.
    Table ProjectA
    Pro_ID Number(10)
    Project_name Varchar(50)
    Pro_date Date
    As per above posting, I created the table in object editor, created the data rule
    NAME_NOT_NULL (ie project name not null). I specified the shadow table name as ProjectA_ERR
    In mapping editor, I have projectA as source. I did not find error table name and defined data rules in table properties. It is not showing up the ERR group in source table
    How do we bring the defined data rules and error table into mapping?
    Are there any additional steps/process?
    Any idea ?
    Thanks in advance.
    RI

    Hi,
    Thanks for your reply/pointer. I reviewed the blog. It is interesting.
    What is the version of OWB used in this blog?
    After defining data rule/shadow table, I deployed the table via CC. It created a error table and created the all the source coulmns in alphabatical order. If I have the primary key as 1st coulmn (which does not start with 'A') in my source, it will apprear middle of of columns in error table.
    How do we prevent/workaround this?
    If I have source(view) in sch A, how do we create Error table in Sch B for source(view)?
    Is it feasible?
    I brought the error table details in mapping. Configured the data rules/error tables.
    If I picked up 'MOVE TO ERROR' option, I am getting "VLD-2802 Missing delete matching criteria in table. the condition is needed because the operator contain at least one data rule with a MOVE TO ERROR action"
    On condition Loading - I have 'All constraints' for matching criteria.
    I changed to "no constraints' still I get the above error.
    If I change to 'REPORT' option instead of 'MOVE TO ERROR' option, error goes off.
    Any idea?
    Thanks in advance.
    RI

  • How to use BKPF and BSEG without using  inner join

    Hi,
    can anybody plz tell me the logic about how to complete the report without inner joining bkpf and bseg.Is this report can be really be made by using only bseg,bkpf ?
    *selection-criteria .
    BKPF-USNAM
    BKPF-CPUDT
    BKPF-BUDAT
    BKPF-GJAHR
    BKPF-BUKRS
    BKPF-BELNR
    BSEG-SAKNR
    BSEG-LIFNR
    BSEG-KUNNR
    BSEG-ZUONR
    BSEG-SGTXT
    Output fields required.
    BKPF-BUKRS
    BKPF-BELNR
    BKPF-GJAHR
    BKPF-MONAT
    BKPF-BLART
    BKPF-CPUDT
    BKPF-BLDAT
    BKPF-BUDAT
    BKPF-USNAM
    BKPF-XBLNR
    BKPF-STBLG
    BKPF-BKTXT
    BKPF-WAERS
    BKPF-KURSF
    BSEG-BUZEI
    BSEG-BSCHL
    BSEG-KOART
    BSEG-UMSKZ
    BSEG-SHKZG
    BSEG-MWSKZ
    BSEG-PSWBT
    BSEG-PSWSL
    BSEG-DMBTR
    BSEG-SAKNR
    BSEG-HKONT
    BSEG-KOSTL
    BSEG-KUNNR
    BSEG-VBELN
    BSEG-LIFNR
    BSEG-ANLN1
    BSEG-ANLN2
    BSEG-AUFNR
    BSEG-MATNR
    BSEG-MENGE
    BSEG-MEINS
    BSEG-ZUONR
    BSEG-SGTXT
    Thanks,
    Rahman
    Moderator Message: Please search before posting your question. Thread locked.
    Edited by: Suhas Saha on Jan 31, 2012 3:07 PM

    Quick question - what's preventing your from using built-in functions?
    I suggest mapping your Time Dim to a standard Time Dim and work with it - you'll save a lot more time. You'd even need this table if you wanted to work around Todate/AGO.
    It is possible to model this functionality w/o functions, but it'll be time consuming task, similar to using Time Series Wizard in Siebel Analytics. You'll need to build aliases and views along with some complex joins (such as TIME.KEY=TIME.KEY-365), introduce a bunch of variables to control. Also, you might not get much flexibility in terms of years. For each year, you'd need an alias table. (TIME_DIM_PY).

Maybe you are looking for

  • How do I get marked text (text marked in a textarea with mouse)

    Hi. I want to implement a method that saves marked text in a textarea in a string. With marked text I mean text that the user marked with its mouse. Is there a method already in the JAVA library? Yours RB

  • Product-sku-output-config.xml - Is there a schema definition (XSD or DTD)?

    For the product-sku-output-config.xml file (used to define the set of product and sku attributes that are sent to Endeca from ATG as part of the Baseline Index process, as defined in chapter 4 of the ATGEndecaIntegrationGuide.pdf, 10.1.2 version), is

  • Regarding Constraints in database ( increase or decrese performance)

    Hi all i want to ask one thing that should be use constraints in our tables? I have a doubt that when we query that particular table then all the containts are also accessed... In other case if we use less constraints then it will increse the perform

  • Simple Sproc Parameters question

    Team, MY ENVIRONMENT SQL 2005, Crystal Reports for Visual Studio 2005 MY PROBLEM I am authoring both a sproc and a report, so I have full control over the design.  I am a SQL expert and also a Crystal 8.5 expert. I have done the Sproc-Report connecti

  • Can I purchase an extended warranty for my iPhone 4?

    I purchased my iphone 4 in February 2011.  I was told I could extend my warranty for one year for $75.  Now, I heard there is a new warranty for the new iphone 4S which means I can not extend my warranty. Anyone know if I can still purchase an extend