Prob with joins(5 tables)

Hi All,
I am facing problem to join 5 tables. it is giving more records. please help.
TABLE 1 : Study
Study_id     Study_name
101        CFFFTY01TABLE 2: Study_site:
study_id        site
101              01
101              02
101              03Table 3 : Site_info
Site        Country
01          hyd
02          chennai
03          mumbaitable 4 : details
study_id  error_id           open_date     closed_date
101        abc01          01jan2013     05jan2013
101     abc02          03jan2013     03jan2013
101     abc03          05jan2013     06jan2013table 5 :error_details
error_id      closed_by
abc01      Murali
abc02     geetha
abc03         ramu--------------------------------------------------------------------------------------------------------------------------------------
actullay main table is table 4 :
I want output like below:
study_name     site     country     error_id     open_date     closed_date     closed_by
CFFFTY01     1     hyd     abc01     1-Jan-2013     5-Jan-2013     murali
CFFFTY02     2     chennai     abc02     3-Jan-2013     3-Jan-2013     geetha
CFFFTY03     3     mumbai     abc03     5-Jan-2013     6-Jan-2013     ramui tired but it is giving more than 3 records. plz help.
Edited by: BluShadow on 21-Mar-2013 08:16
added {noformat}{noformat} tags for readability.  Please read: {message:id=9360002} and learn to do this yourself in future.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

995263 wrote:
Hi All,
I am facing problem to join 5 tables. it is giving more records. please help.
.. cut ..
i tired but it is giving more than 3 records. plz help.You mean you are getting this?...
SQL> with study as (select 101 as study_id, 'CFFFTY01' as study_name from dual)
  2      ,study_site as (select 101 as study_id, '01' as site from dual union all
  3                      select 101, '02' from dual union all
  4                      select 101, '03' from dual)
  5      ,site_info as (select '01' as site, 'Hyd' as country from dual union all
  6                     select '02', 'Chennai' from dual union all
  7                     select '03', 'Mumbai' from dual)
  8      ,details as (select 101 as study_id, 'abc01' as error_id,  date '2013-01-01' as open_date, date '2013-01-05' as closed_date from dual union all
  9                   select 101, 'abc02', date '2013-01-03', date '2013-01-03' from dual union all
10                   select 101, 'abc03', date '2013-01-05', date '2013-01-06' from dual)
11      ,error_details as (select 'abc01' as error_id, 'Murali' as closed_by from dual union all
12                         select 'abc02', 'Geetha' from dual union all
13                         select 'abc03', 'Ramu' from dual)
14  --
15  -- end of test data
16  --
17  select s.study_name
18        ,ss.site
19        ,si.country
20        ,d.error_id
21        ,d.open_date
22        ,d.closed_date
23        ,ed.closed_by
24  from   details d
25         join error_details ed on (d.error_id = ed.error_id)
26         join study s on (s.study_id = d.study_id)
27         join study_site ss on (ss.study_id = s.study_id)
28         join site_info si on (si.site = ss.site)
29  order by 1
30  /
STUDY_NA SI COUNTRY ERROR OPEN_DATE            CLOSED_DATE          CLOSED
CFFFTY01 01 Hyd     abc03 05-JAN-2013 00:00:00 06-JAN-2013 00:00:00 Ramu
CFFFTY01 01 Hyd     abc02 03-JAN-2013 00:00:00 03-JAN-2013 00:00:00 Geetha
CFFFTY01 01 Hyd     abc01 01-JAN-2013 00:00:00 05-JAN-2013 00:00:00 Murali
CFFFTY01 02 Chennai abc03 05-JAN-2013 00:00:00 06-JAN-2013 00:00:00 Ramu
CFFFTY01 02 Chennai abc02 03-JAN-2013 00:00:00 03-JAN-2013 00:00:00 Geetha
CFFFTY01 02 Chennai abc01 01-JAN-2013 00:00:00 05-JAN-2013 00:00:00 Murali
CFFFTY01 03 Mumbai  abc03 05-JAN-2013 00:00:00 06-JAN-2013 00:00:00 Ramu
CFFFTY01 03 Mumbai  abc02 03-JAN-2013 00:00:00 03-JAN-2013 00:00:00 Geetha
CFFFTY01 03 Mumbai  abc01 01-JAN-2013 00:00:00 05-JAN-2013 00:00:00 Murali
9 rows selected.
SQL>That's because each details record has a study_id of 101 and the study sites have 3 record (01,02 and 03) for site_id 101. So each detail record get's shown with each of the study sites as there is no data to indicate which study site the detail record relates to (i.e. you are missing a relationship in your data)
How are you expecting to get:
study_name     site     country     error_id     open_date     closed_date     closed_by
CFFFTY01     1     hyd     abc01     1-Jan-2013     5-Jan-2013     murali
CFFFTY02     2     chennai     abc02     3-Jan-2013     3-Jan-2013     geetha
CFFFTY03     3     mumbai     abc03     5-Jan-2013     6-Jan-2013     ramuwhen you do not have CFFFTY02 or CFFFTY03 in your data?
Essentially the data you have provided does not meet the required output. Fix the data first.

Similar Messages

  • Update statement with joining other tables

    Hi ,
    I have two table one is containing xml file , basically i need to read from those xml file then update to another table based on some condition.
    UPDATE TRCB_XBRL_STG_2 STG
    SET PROFIT =
      case when xbrl.isconsolidatedacc='Y' and EXTRACTVALUE(XBRL.XBRLFILE,'//PROFIT ', 'xmlns:acra="..."') is not null
      THEN EXTRACTVALUE(XBRL.XBRLFILE,'//PROFIT ', 'xmlns:acra="..."')
      WHEN XBRL.ISCONSOLIDATEDACC='N' AND EXTRACTVALUE(XBRL.XBRLFILE,'//PROFIT ', 'xmlns:acra="..') IS NOT NULL
      THEN extractValue(XBRL.xbrlfile,'//PROFIT ', 'xmlns:acra=".."')
      ELSE STG.PROFIT
      END,
      SET REVENUE=
      case when xbrl.isconsolidatedacc='Y' and EXTRACTVALUE(XBRL.XBRLFILE,'//REVENUE', 'xmlns:acra="..."') is not null
      THEN EXTRACTVALUE(XBRL.XBRLFILE,'//REVENUE.', 'xmlns:acra="..."')
      WHEN XBRL.ISCONSOLIDATEDACC='N' AND EXTRACTVALUE(XBRL.XBRLFILE,'//REVENUE', 'xmlns:acra="..') IS NOT NULL
      THEN extractValue(XBRL.xbrlfile,'//REVENUE', 'xmlns:acra="REVENUE"')
      ELSE STG.REVENUE
      END,
      ... (around 100 columns)
    FROM  TRCB_XBRL xbrl ,TRCB_XBRL_STG_2 STG
    WHERE STG.XBRL_ID = XBRL.XBRL_ID Number of columns are around 100 , please anyone suggest how to use update statement with joining two tables.

    Hi,
    If all the values needed to update a given row of table_x are coming from the same row of table_y (or from the same row of a result set of a query involving any number of tables), then you can do something like this:
    UPDATE  table_x  x
    SET     (col1, col2, col3, ...)
    =     (
             SELECT  NVL (y.col1, x.col1)
             ,         NVL (y.col2, x.col2)
             ,         NVL (y.col3, x.col3)
             FROM    table_y  y
             WHERE   x.pkey   = y.expr
             AND         ...
    WHERE   ...
    ;If the WHERE clause depends on the same row of table_y, then it will probably be simpler and more efficient to use MERGE instead of UPDATE.
    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.
    In the case of a DML operation (such as UPDATE) the sample data should show what the tables are like before the DML, and the results will be the contents of the changed table(s) after the DML.
    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 {message:id=9360002}

  • Performance issue with joins on table VBAK, VBEP, VBKD and VBAP

    hi all,
    i have a report where there is a join on all 4 tables VBAK, VBEP, VBKD and VBAP.
    the report is giving performance issues because of this join.
    all the key fields are used for the joining of tables. but some of the non-key fields like vbap-vstel, vbap-abgru and vbep-wadat are also part of select query and are getting filled.
    because of these there is a performance issue.
    is there any way i can improve the performance of the join select query?
    i am trying "for all entries" clause...
    kindly provide any alternative if possible.
    thanks.

    Hi,
    Pls perform some of the below steps as applicable for the performance improvement:
    a) Remove join on all the tables and put joins only on header and item (VBAK & VBAP).
    b) code should have separate select for VBEP and VBKD.
    c) remove the non key fields from the where clause. Once you retrieve data from the database into the internal table, sort the table and delete the entries which are not part of the non-key fields like vstel, abgru and wadat.
    d) last option is you can create index in the VBAP & VBEP table with respect to the fields vstel, abgru & wadat ( not advisable)
    e) buffering option on database tables also possible.
    f) select only the fields into the internal table that are applicable for the processing logic and also the select query should contaian the field names in the same order as mentioned in the database table.
    Hope this helps.
    Regards
    JLN

  • Problem with joining 3 tables

    Hi,
    The following is my join code and internal table declaration:
    BEGINOF/ENDOF INTERNAL TABLE
    DATA: BEGIN OF I_MARC_VALUES OCCURS 0,
            WERKS LIKE MARC-WERKS,
            DISPO LIKE MARC-DISPO,
            DISMM LIKE MARC-DISMM,
            ZZLIFNR LIKE MARC-ZZLIFNR,
            MMSTA LIKE MARC-MMSTA,
            MATNR LIKE MARA-MATNR,
            MAKTX LIKE MAKT-MAKTX,
            EKGRP LIKE MARC-EKGRP,
          END OF I_MARC_VALUES.
    SELECT
    MARC~WERKS
    MARC~DISPO
    MARC~DISMM
    MARC~ZZLIFNR
    MARC~MMSTA
    MARA~MATNR
    MAKT~MAKTX
    MARC~EKGRP
    FROM MARC
    INNER JOIN MARA ON MARAMATNR = MARCMATNR
    INNER JOIN MAKT ON MAKTMATNR = MARCMATNR
    INTO CORRESPONDING FIELDS OF TABLE I_MARC_VALUES
    WHERE EKGRP =  P_GROUP.
    BREAK-POINT.
    WRITE: / I_MARC_VALUES.
    However, the output produces a blank screen.
    What is the problem and what can i do to solve it?
    Points will be rewarded and all answers will be greatly appreciated.
    Thank You,
    John

    Hi john,
    Use the loop stamemnt and don't go for inner join, better use for all entries,so that ur processing will be faster..
    REPORT  ZNEW                                    .
    PARAMETER P_GROUP TYPE MARC-EKGRP.
    *BEGINOF/ENDOF INTERNAL TABLE
    DATA: BEGIN OF I_MARC_VALUES OCCURS 0,
    WERKS LIKE MARC-WERKS,
    DISPO LIKE MARC-DISPO,
    DISMM LIKE MARC-DISMM,
    *ZZLIFNR LIKE MARC-ZZLIFNR,
    MMSTA LIKE MARC-MMSTA,
    MATNR LIKE MARA-MATNR,
    MAKTX LIKE MAKT-MAKTX,
    EKGRP LIKE MARC-EKGRP,
    END OF I_MARC_VALUES.
    SELECT
    MARC~WERKS
    MARC~DISPO
    MARC~DISMM
    *MARC~ZZLIFNR
    MARC~MMSTA
    MARA~MATNR
    MAKT~MAKTX
    MARC~EKGRP
    FROM MARC
    INNER JOIN MARA ON MARAMATNR = MARCMATNR
    INNER JOIN MAKT ON MAKTMATNR = MARCMATNR
    INTO CORRESPONDING FIELDS OF TABLE I_MARC_VALUES
    WHERE EKGRP = P_GROUP.
    *BREAK-POINT.
    LOOP AT I_MARC_VALUES.
    WRITE: / I_MARC_VALUES-WERKS.
    ENDLOOP.
    try with this program..It's executing..
    Reward if it's useful..
    Reg,
    Manoj.

  • Help with joining one table to several

    I have the following table
    MSELECT
    Res_ID
    Res_type
    34
    501
    56
    501
    72
    501
    81
    502
    90
    502
    100
    502
    47
    503
    48
    503
    The RES_ID will link to different tables such as tablea, tableb or tablec based on the RES_Type value .g. RES_Type ID 501 will link to tableA and 502 will link to TableB and 503 will link to TableC.
    I have created the following query:
    Select * from MSSELECT MSEL
    Inner join tablea  ta on
    Ta.id = MSEL.ID and
    Res_type = 501
    Inner join tableb tb on
    Tb.id = MSEL.ID and
    Res_type = 501
    If I run the following query then results are returned.
     Select * from MSSELECT MSEL
    Inner join tablea  ta on
    Ta.id = MSEL.ID and
    Res_type = 501
    However if I run the following query it is returning no results:
    Select * from MSSELECT MSEL
    Inner join tablea  ta on
    Ta.id = MSEL.ID and
    Res_type = 501
    Inner join tableb tb on
    Tb.id = MSEL.ID and
    Res_type = 501

    Try:
    Select * from MSSELECT MSEL
    LEFT OUTER join tablea  ta on
    Ta.id = MSEL.ID and
    Res_type = 501
    LEFT OUTER  join tableb tb on
    Tb.id = MSEL.ID and
    Res_type = 501
    Best Wishes, Arbi; Please vote if you find this posting was helpful or Mark it as answered.

  • Probs with accessing games table

    here is my problem I cant get into yahoo pool it lets me go into lounge it lets me pick a table and it says Im at that table but it wont let me sit down and play can someone help me with that ty AMBER

    Uh... so what are you doing at Sun's Java developers forum? Why don't you call Yahoo support?

  • Join fact table with higher dimension level

    how do i join fact tables with higher dimension levels with discoverer?
    fact with detail at level C
    measure X
    dimension with
    D->C->B->A
    E->C
    level
    A B C
    1------1------1
    2------2------1
    3------2------1
    join between fact X and dimension level C
    X=3*C because of sum(X) in discoverer and 3xC in dimension
    is there a way to get correct values for X without creating a dimension like
    D->C
    E->

    another way of asking this is whether you can create a summary table in Discoverer at a higher level than a dimension's fundamental grain. In other words - the summary examples in the documentation all describe leaving out one or more of your dimensions... they are either left in or completely taken out. But, some of the most effective summarization occurs when you summarize daily data to a monthly level. Assuming that I have a sales table (at a daily level, and a key value sales_date), and a table date_dim (primary key sales_date), I would like to create a summary sales_month_summary where the sales are grouped on month_year (which is a field in the sales_date table).
    How is this done? I suspect that we can't use the date_dim table with the summary (due to the problems noted by the poster above). Do we have to create another table "month_dim"? Do we have to fold all of the desired date attributes (month, quarter, year) into the summary? Obviously we'd like to re-use all of the pertinent already existing date items (quarter, month, year, etc.), not recreate them over again, which would result in essentially two sets of items in the EUL. [One used for this month summary, and another used for the detail.]
    I searched the forum - someone asked this same question back in 2000 - there was no answer provided.
    The only other thought I have is to "snowflake" the date_dim into two tables and two folders, one at a date level, another at the month level. Then the detail tables can connect to date_dim (which is linked to month_dim), while the summary data can connect directly to month_dim.

  • Left outer join 3 tables with where-statement

    Hi folks,
    I hope you can understand (and maybe solve) my problem.
    Generally I try to left outer join three tables. The third table is used for a WHERE-statement.
    The three table structures are the following:
    table 1 (user)   
    user1 | key
    table 2 (detail)  
    key | ID
    table 3 (header)
    ID | user2                 
    ...and I want to achieve the following structure (as example filled with data):
    user | key | ID
    |-----|----
    xy    | a    | 001
    xy    | b    | #
    z     | b     | #
    The clue ist the usage of the third table. I need the table to set user1 and user2 equal (WHERE) but there are two problems:
    1) Obviously I can't left outer join two tables with each other. In this case I already used the 'key' of table 1 to join it with the 'key' of table 2. So I can't left outer join the 'ID' of table 2 with the 'ID' of table 3. Error message that I can only left outer join a table once. Any proposals?
    2) I have to include a WHERE to equal user1 with user2. But I am not allowed to use the user2 from table 3 because of the left outer join.
    I tried this coding:
    SELECT auser1 akey b~id INTO TABLE itab FROM ( table1 AS a
      LEFT OUTER JOIN table2 AS b ON akey = bkey )
      LEFT OUTER JOIN table3 AS c ON bID = cID )
      WHERE auser1 = cuser2.
    I would really appreciate your help.
    Regards
    MrclSpdl

    IF you want to join a DB table with an internal table, you need to use the 'FOR ALL ENTRIES' statement.
    select dbfields
    into table itab2
    from dbtab
    for all entries in itab
    where dbfield1 = itab-field1.
    This will get you a second internal table with all the corresponding data for the first selection.  You can then join them with a loop through the first table and a read table on the second table (for 1 - 1 relation) or a nested loop statement on both tables (for 1 - N relation).  Make itab a hashed table when using read table with key, use a sorted table if you need to loop without key access.
    Regards,
    Freek

  • Joining a table with all_tab_columns

    How is it possible to join a table with the tab_columns?
    The query im trying to establish is that in my table they are 12 columns with months names. So under an input variable im trying to return the required values with the selected months. The only way i could think of to get the months to connect with the tab_columns table.
    Any suggestion is really appreciated
    SELECT bust,
    Sum(jan) JAN,
    Sum(feb) FEB,
    Sum(mar) MAR,
    Sum(apr) APR,
    Sum(may) MAY,
    Sum(jun) JUN,
    Sum(jul) JUL,
    Sum(aug) AUG,
    Sum(sep) SEP,
    Sum(oct) OCT,
    Sum(nov) NOV,
    Sum(DEC) DECC
    FROM budget a,all_tab_columns b
    WHERE vsl_code = 4602
    AND code = 1
    AND year=2013
    AND account_code='30'
    AND b.table_name='BUDGET'
    AND b.column_name IN
                         (SELECT column_name
                          FROM (SELECT Column_name, ROWNUM r
                                        FROM all_tab_columns b
                                        WHERE table_name = 'BUDGET'
                                        AND Column_id BETWEEN 3 AND 14
                                        ORDER BY column_id)
                          WHERE r BETWEEN 2 AND 3 ) --Returns February,March
    group by bust;

    Sorry, I don't understand what you're trying to do or why you think you need to join to all_tab_columns. Perhaps you could post the definition of the budget table, some sample data, and the results you're hoping to see.
    Without that, I don't see why you can't just do this:
    SELECT bust,   
    Sum(jan) JAN,   
    Sum(feb) FEB,   
    Sum(mar) MAR,   
    Sum(apr) APR,  
    Sum(may) MAY,  
    Sum(jun) JUN,   
    Sum(jul) JUL,   
    Sum(aug) AUG,   
    Sum(sep) SEP,   
    Sum(oct) OCT,  
    Sum(nov) NOV,   
    Sum(DEC) DECC  
    FROM budget a
    WHERE vsl_code = 4602  
    AND code = 1  
    AND year=2013  
    AND account_code='30' 
    group by bust;

  • Joining Two Tables with Total Amount

    Hi All,
    I'm trying to join to tables P02 and P30 on the invoice no fields but getting duplicates. In table P30 we need to sum the payment column per invoice to get the actual payment amount. This then needs to Join to table P02. I have uploaded  sample
    data on this link and provided an example on how the output should like.
    https://app.box.com/s/pu8oa4f3jhrhm0ylshdz2fuo7541vn4z
    Thanks
    Jag

    I figured out why the duplicates appear. I'm attaching another table supplier to fill in the missing propcode when running the query below
    SELECT P02.P02_UNIQUE, p30.PROP_CODE, P02.SUPP_ALPHA+P02.SUPP_NUMERIC As SupplierCode, P02.INV_ALPHA+P02.INV_NUMERIC AS InvoiceNo,TotalPayment, Year, Month
    FROM P02
    CROSS APPLY (
                    SELECT PROP_CODE, SUM(TOTAL_AMOUNT) AS TotalPayment, P30.INVOICE_NUMB, DATEPART(year,[CREATED_DATE_SQL]) AS [Year], DATEName(Month,[CREATED_DATE_SQL]) AS [Month]
                    FROM dbo.P30
                    WHERE P02.INV_ALPHA+P02.INV_NUMERIC = P30.INVOICE_NUMB
                    GROUP BY PROP_CODE, COST_CENTRE, DATEPART(year,[CREATED_DATE_SQL]), DATEName(Month,[CREATED_DATE_SQL]), P30.INVOICE_NUMB
                    )P30
    Where P02.SUPP_ALPHA+P02.SUPP_NUMERIC = '668'
    Result below and the last row the prop_code is missing
    I have another table supplier which has the suppliercode and propcode so was trying to use the prop_code field from supplier table instead of P30 table to fill in the gap. But when i do that i get duplicates and wrong values.
    I have updated the sample data with supplier table.

  • Join the Table with View

    Hi,
    My doubt is can I join the table with view in the below where clause condition in the query. If yes, the below query will take 4 hrs to execute it. Can I do the below query to write as simplest?
    SELECT *
      FROM uabpymt p, uavlsum l
    WHERE uabpymt_appl_ind = 'N'
       AND uabpymt_amount > 5
       AND l.uavlsum_balance < 0
       AND l.uavlsum_cust_code = p.uabpymt_cust_code
       AND l.uavlsum_prem_code = p.uabpymt_prem_codeuavlsum ---view
    uabpymt ---table
    The view script below:
    CREATE OR REPLACE VIEW UAVLSUM
    (UAVLSUM_CUST_CODE, UAVLSUM_PREM_CODE, UAVLSUM_AMOUNT, UAVLSUM_BALANCE)
    AS
    SELECT cust_code,
           prem_code,
           SUM(amount),
           SUM(balance)
    FROM (
    SELECT uabopen_cust_code cust_code,
           uabopen_prem_code prem_code,
           uabopen_billed_chg amount,
           uabopen_balance balance
    FROM   uimsmgr.uabopen
    UNION ALL
    SELECT uabpymt_cust_code,
           uabpymt_prem_code,
           uabpymt_amount * -1,
           uabpymt_balance * -1
    FROM   uimsmgr.uabpymt
    UNION ALL
    SELECT uabadje_cust_code,
           uabadje_prem_code,
           uabadje_balance,
           to_number(0)
    FROM   uimsmgr.uabadje
    WHERE  uabadje_balance <> 0)
    GROUP BY cust_code,
             prem_code

    Find the below explain plan output which we get from the execute the query
    STATEMENT_ID            TIMESTAMP     REMARKS        OPERATION     OPTIONS          OBJECT_NODE OBJECT_OWNER            OBJECT_NAME            OBJECT_INSTANCE      OBJECT_TYPE OPTIMIZER      
                16/01/2009 05:57:24                   SELECT STATEMENT                                                                                                                           RULE                                                                                                                                                   
                16/01/2009 05:57:24                   FILTER                                                                                                                                                                                                                                    
                16/01/2009 05:57:24                   SORT           GROUP BY                                                                                                                                                                                                                      
                16/01/2009 05:57:24                   TABLE ACCESS           BY INDEX ROWID                     UIMSMGR                     UABPYMT                                1                                             
                16/01/2009 05:57:24                   NESTED LOOPS                                                                                                                                                                                                                                  
                16/01/2009 05:57:24                   VIEW                                                   UIMSMGR                                                         3                                             
                16/01/2009 05:57:24                   UNION-ALL                                                                                                                                                                                                                              
                16/01/2009 05:57:24                   TABLE ACCESS           FULL                            UIMSMGR                     UABOPEN                                    4                                             
                16/01/2009 05:57:24                   TABLE ACCESS           FULL                            UIMSMGR                     UABPYMT                                    5                                             
                16/01/2009 05:57:24                   TABLE ACCESS           FULL                            UIMSMGR                     UABADJE                                    6                                                                                                                                                         
                16/01/2009 05:57:24                   INDEX       RANGE SCAN                                   UIMSMGR                     UABPYMT_CUST_PREM_INDEX                        NON-UNIQUE                                                                                                                           
    Index column:
    Table name :UABPYMT
    Column Name
    UABPYMT_APPL_IND  
    UABPYMT_APPROVED_IND    
    UABPYMT_PYMT_DATE          
    UABPYMT_SOURCE    
    UABPYMT_ORIGIN                   
    UABPYMT_CUST_CODE          
    UABPYMT_PREM_CODE         
    UABPYMT_PYMT_DATE          
    UABPYMT_AR_TRANS             
    UABPYMT_GL_IND                  
    UABPYMT_GL_POST_DATE     
    UABPYMT_AR_TRANS  

  • Update openquery remote table with join

    Hi All,
    I have a problem with OPENQUERY update on remote table. I've googled for days, and can't solve the problem.
    Here is the problem:
    Local server MS SQL 2005.
    Remote server: MySQL.
    The linked server is communicating through MySQL ODBC 5.1
    I created the following code for update (tried many other version too, this is the last one):
    update openquery(Remoteserver,'select products_id, products_price, products_last_modified, products_stock from products1')
    set
    products_price=A.products_price,
    products_stock=A.products_stock,
    products_last_modified=getdate()
    FROM
    (select * from vi_products_update) AS A INNER JOIN
    openquery(octopus, 'select products_id from products1')AS B
    ON A.products_id=B.products_id
    When I run the query the columns are updated with the same value, for each record. It looks the value is the first which match the criteria. Each (remote and local) table has as primary key products_id. In this example I used as result set for local a view, but I have the same result if I use a table.
    the products_last_modified column is updated in order, and if I update for e.g. the products_price with a constant that is ok too. The problem should be somewhere with join, but I can' get it where.
    THX for any help
    ab

    Hi
    Did you ever solve this problem
    I have the same issue trying to update many rown in a MySQL table from SQL2005 using the syntax below,
    UPDATE
    openquery(DEV,'select id, `desc` from todLocationGroups')
    SET [desc] = V.Destination_Group FROM
    (select * from VTM_TOD_Rate) as V inner join
    openquery(DEV,'select id, `desc` from todLocationGroups') as K
    ON K.id = V.TOD_LG_ID
    but i get this error
    OLE DB provider "MSDASQL" for linked server "KAYOTE_DEV" returned message "Row cannot be located for updating. Some values may have been changed since it was last read.".
    Msg 7343, Level 16, State 4, Line 1
    The OLE DB provider "MSDASQL" for linked server "KAYOTE_DEV" could not UPDATE table "[MSDASQL]". The rowset was using optimistic concurrency and the value of a column has been changed after the containing row was last fetched or resynchronized.

  • Join EQUI table with other table so as get address detail.

    Hi All,
    Can any one help me in the following case :
    I have to pass Equipment No. EQUNR on the selection screen and get Address detail (city, region, state, country, zipcode )
    now I am getting all this address related field in KNA1 table. Also I am able to join this two table with
    KNA1-KUNNR join EQUI-KUNDE as common field.
    Turning point
    when I am passing test data of Equipment No. EQUNR 60099204 I am not getting the address detail,
    because after passing EQUNR I am not getting KUNNR.
    So can any one please help me in joining EQUI table to some other table with field name so that I can get the address detail.
    Thanks

    Hi,
    The join between the table EQUI-kunde  join  KNA1-kunnr is ok but it not working for every value.
    Example :-
    In EQUI table when we pass  Equnr - 60099204 we need to get some value in KUNDE field, then only it will join to KNA1 table. But this is not happening, I am not getting value for KUNDE, hence join is not performing.
    So I need some other solution so that when we pass EQunr we can get the address details
    one thing more equnr  60099204 is having address detail, if we'll check IE03 (transaction by clicking address envelop)
    Thx.

  • Named query with join tables

    I have two tables
    - Process_Master (EVENT_ID, EVENT_TYP, STATUS)
    - Rel_Event( EVENT_ID, USERID, EVENT_DATE, RMKS)
    They have one-to-one relationship linked by EVENT_ID.
    I would like to create a named query like below joining 2 tables together.
    Do I need to create any class descriptor first and how? I want this query to be available from the ADF data control so I can drag and drop this to my JSP page as a ADF table. I have no problem in working with single table. I have read thru the developer guide and try out many things like multitable info, aggregate mapping and couldn't figure out how this can be done. Please help!!!
    SELECT A.EVENT_ID,B.EVENT_DATE, A.STATUS, B.RMKS
    FROM PROCESS_MASTER A, REL_EVENT B
    WHERE A.EVENT_ID = B.EVENT_ID
    AND A.STATUS = 'P';
    ********/

    I have tried the below but fail to retrieve any rows. Please help!
    Expression aid = new ExpressionBuilder(ProcEventMaster.class).get("event_id");
    Expression bid = new ExpressionBuilder(RelEvent.class).get("event_id");
    ReportQuery reportQuery = new ReportQuery(ProcEventMaster.class,aid.equal(bid));
    reportQuery.addAttribute("a_id", aid);
    reportQuery.addAttribute("b_id", bid);
    reportQuery.addAttribute("eventDate",bid.get("event_date"));
    reportQuery.addAttribute("remarks",bid.get("rmks"));
    reportQuery.setSelectionCriteria(aid.get("status").equal("P"));
    List<RelEvent> results =
    (List<RelEvent>)session.executeQuery(reportQuery);session.release();
    return results;

  • How join a type table data with a real table.

    Hello,
    I want make a join with a type table data and real table.
    But i don't know how make this.
    Can you help me?????
    I have this pl/sql:
    SET LINESIZE 5000;
    DECLARE
    valor NUMBER;
    TYPE reg_tablita IS RECORD
    (cuenta B_TB_CTAFACTU.B_CO_CTAFACTU%TYPE,sistema B_TB_CTAFACTU.B_CO_SISTEMA%TYPE);
    TYPE Tabla IS TABLE OF reg_tablita INDEX BY BINARY_INTEGER;
    I                         BINARY_INTEGER;
    Array Tabla;
    BEGIN
    Array(1).cuenta:='000001';
    Array(1).sistema:='AA';
    Array(2).cuenta:='000002';
    Array(2).sistema:='BB';
    Array(3).cuenta:='000003';
    Array(3).sistema:='CC';
    Array(4).cuenta:='000004';
    Array(4).sistema:='DD';
    Array(5).cuenta:='000005';
    Array(5).sistema:='EE';
    SELECT count(*) into valor FROM
    TABLA A, Array WHERE
    B_CO_CTAFACTU=Array.cuenta and B_CO_SISTEMA=Array.sistema
    quit;
    Thanks very much!!!!

    You need to have the types defined as SQL types (created in database) in order to be able to use them for joining. PL/SQL object types can not be joined.

Maybe you are looking for

  • Error while updating to target type INFOCUBE

    Hi, After BI SP16 Upgrade, we noticed that data load to a cube with DTP (7X DS) with partioning active, it would error out saying, "Error while updating to target " " type INFOCUBE....we applied note '1148007' and did reactivation of related structur

  • Click wheel iPod connectoiin troubles

    I am having troubles with my click wheel 20 GB iPod (colorless screen). When I attempt to turn it on, it displays the folder and exclamation point icon. When I connect it to my computer (windows XP), it sometimes shows the do not disconnect screen an

  • Weblogic server 8.1 SP2 to SP6 ugrade

    Hello All Am looking for any document that would outline steps to upgrade weblogic 8.1 SP2 to SP6. Can we directly upgrade to SP6 ? Found the patch 9479129 BEA WebLogic Platform: Patchset WEBLOGIC PLATFORM 8.1 WITH SP6 UPGRADE INSTALLER but the readm

  • Record History in R12 HTML Forms

    Hi all, Would greatly appreciate if anyone could shed some light on how I can access the (Help -> Record History) option in some of the HTML versions of the R12 standard forms, e.g. customer / supplier master. I need this to look at "Created By:" "Cr

  • Why is my Itunes Video Player Messed Up?

    I have recently downloaded some episodes of one my favorite TV shows but I can't play them properly. The audio and video are way out of sync, the audio keeps going off(I have to pause and play again to get it back), and the video is very lagged. Is t