How do you join two tables from different Oracle schemas using a subquery

I am trying to join two tables from different Oracle schemas using a subquery. I can extract data from each of the tables without a problem. However, when I combine the select statements using a subquery I get the Oracle error *'ORA-00936: missing expression'*. Since each SELECT statement executes on its own without error I don't understand what is missing. The result set I am trying to get is to match up the LINE_ID from PDTABLE_12_1 in schema DD_12809 with the MAT_DESCRIPTION from table PDTABLE_201 in schema RA_12809.
The query is as follows:
sql = "SELECT [DD_12809].[PDTABLE_12_1].LINE_ID FROM [DD_12809].[PDTABLE_12_1] JOIN " _
+ "(SELECT [RA_12809].[PDTABLE_201].MAT_DESCRIPTION " _
+ "FROM [RA_12809].[PDTABLE_201]) AS FAB " _
+ "ON [DD_12809].[PDTABLE_12_1].PIPING_MATER_CLASS = FAB.PIPING_MATER_CLASS"
The format of the query is copied from a SQL programming manual.
I also tried executing the query using a straight JOIN on the two tables but got the same results. Any insight would be helpful. Thanks!
Edited by: user11338343 on Oct 19, 2009 6:55 AM

I believe you are receiving the error because you are trying to JOIN on a column that doesn't exist. For example you are trying to join on FAB.PIPING_MATER_CLASS but that column does not exist in the subquery.
If you want to do a straight join without a subquery you could do the following
SELECT  DD_12809.PDTABLE_12_1.LINE_ID
,       FAB.MAT_DESCRIPTION
FROM    DD_12809.PDTABLE_12_1
JOIN    RA_12809.PDTABLE_201    AS FAB ON DD_12809.PDTABLE_12_1.PIPING_MATER_CLASS = FAB.PIPING_MATER_CLASS  HTH!

Similar Messages

  • How can i join two libraries from two different users

    how can i join two libraries from two different users in the same computer?

    I should add that you can turn on SHARING where each user can see the other user's library and play stuff out of it. But they can not import those tracks to their own library or put them into their own playlists or burn CDs of the shared library.
    Also note, to do this you need to have the fast switching option enabled with the accounts so both can be running at the same time and both must have iTunes running at the same time.
    Patrick

  • No Easy Way to Join on Tables from Different Schemas

    Hi,
    The company policy does not allow to join on tables from different schemas or use db links...
    I'm tasked to come up with a Perl script that does exactly that - allows for the SELECT statement to do several joins on 3 different schemas. In addition 1 of the schemas is on the different host altogether.
    Upping the privileges for my user and allowing db links is not an option...Can someone, please help me to understand on a conceptual level how would I use Perl and what logic would it have and what would it (perl) do?
    Thank you,

    Court in the wrong job... ;)
    It's like a librarian who is a hard rock artist maintaining the silence in the premises. ;)
    My dear friend, i don't think this is the right place for your requirement. This is the PL/SQL forum. If you have any problem related PL/SQL or SQL you can place that here.
    Regards.
    Satyaki De.

  • How do you swap two variables A and B without using a 3rd variable?  No fun

    How do you swap two variables A and B without using a 3rd variable? No function or method allowed.
    For example:
    Given:
    A = 35
    B = 10
    Result
    A = 10
    B = 35

    How do you swap two variables A and B without using a
    3rd variable? No function or method allowed.
    For example:
    Given:
    A = 35
    B = 10
    Result
    A = 10
    B = 35
    A = A + B  (A = 35 + 10 = 45)
    B = A - B (B = 45 - 10 = 35)
    A = A - B (A = 45 - 35 = 10)

  • How do you swap two variables A and B without using a 3rd variable?

    How do you swap two variables A and B without using a 3rd variable? No function or method allowed.
    For example:
    Given:
    A = 35
    B = 10
    Result
    A = 10
    B = 35

    How do you swap two variables A and B without using a
    3rd variable? No function or method allowed.
    For example:
    Given:
    A = 35
    B = 10
    Result
    A = 10
    B = 35
    A = A + B  (A = 10 + 35 = 45)
    B = A - B (B = 45 - 35 = 10)
    A = A - B (A = 45 - 10 = 35)

  • Join two table in different instance

    Hi,
    I have two table in different instance .
    IMEI in instance A
    RCA_SMART_CARD in instance B
    Below is the desc table :
    SQL> desc RCA_SMART_CARD;
    Name Null? Type
    N_CARD_ID NOT NULL NUMBER(10)
    C_CARD_SERIAL_NUMBER NOT NULL VARCHAR2(20)
    C_SIM_MSISDN VARCHAR2(20)
    C_SIM_IMSI VARCHAR2(20)
    C_LINKED_CARD VARCHAR2(20)
    N_PRO_IDENTIFIER NOT NULL NUMBER(4)
    C_CARD_TYPE VARCHAR2(1)
    N_SIM_STATE NUMBER(1)
    N_EEPROM_SPACE_LEFT NUMBER(9)
    N_VOLATILE_SPACE_LEFT NUMBER(9)
    N_NONVOLATILE_SPACE_LEFT NUMBER(9)
    N_CARD_OPTI NOT NULL NUMBER(15)
    N_PRODUCT_ID NUMBER(10)
    D_CREATION_DATE DATE
    D_MODIFICATION_DATE DATE
    D_STATUS_MODIFICATION_DATE DATE
    SQL> desc IMEI;
    Name Null? Type
    MSISDN NOT NULL VARCHAR2(20)
    IMEI NOT NULL VARCHAR2(16)
    DATE_MOD NUMBER(13)
    IMSI VARCHAR2(18)
    ICCID VARCHAR2(20)
    T_PROF RAW(20)
    EXTRA_DATA VARCHAR2(100)
    If I want to join two table together .
    I want to search the number of record in IMEI that have N_SIM_STATE =1 in RCA_SMART_CARD .
    The MSISDN in IMEI is equal to C_SIM_MSISDN in RCA_SMART_CARD .
    How can I do and what is the sql statment ??
    Please advice .

    First you need to decide, from where you want to execute the query.
    Let us assume it is instance A(as per your example).
    Then what you need to do is:
    1.     Create database link to instance B
    *[url http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_5005.htm]Here* is the semantics.
    2.     After creating the database link to instance B, you can achieve the result set by running the below query:
            SQL> select count(*) from IMEI t1 join RCA_SMART_CARD@<db_link_name> t2 on t1.MSISDN = t2.C_SIM_MSISDN where t2.N_SIM_STATE = 1
            Hope it helps!
    Cheers,
    AA

  • How do I join two tables in the same database and load the result into a destination table in a SSIS package

    Hi,
    I have a query that joins two tables in the same database, the result needs to be loaded in a destination DB table.  How do I do this in SSIS package?
    thank you !
    Thank You Warmest Fanny Pied

    Please take a look at these links related to your query.
    http://stackoverflow.com/questions/5145637/querying-data-by-joining-two-tables-in-two-database-on-different-servers
    http://stackoverflow.com/questions/7037228/joining-two-tables-together-in-one-database

  • Import Data Table from Different DB Schema in BI Administration

    Here is my scenario:
    Tables are imported from different DB schema in Administration. They are then joined together.
    When I select fields from more than one schema in BI Answer, incorrect result is returned.
    Below is the SQL it returns:
    -------------------- Sending query to database named DW_TESTING (id: <<15875>>):
    select D1.c4 as c1,
    D1.c5 as c2,
    D1.c2 as c3,
    D1.c1 as c4,
    D1.c3 as c5
    from
    *(select D1.c1 as c1,*
    D1.c2 as c2,
    D1.c3 as c3,
    D1.c4 as c4,
    D1.c5 as c5
    from
    *(select sum(T34.PRODUCT_SALES) as c1,*
    T52.DESCRIPTION as c2,
    T52.BE_TYPE as c3,
    T137.YEAR as c4,
    T137.QUARTER as c5,
    ROW_NUMBER() OVER (PARTITION BY T52.BE_TYPE, T137.QUARTER ORDER BY T52.BE_TYPE ASC, T137.QUARTER ASC) as c6
    from
    BEADMIN.BE_MASTER T52,
    DWADMIN.DATE_MASTER T137,
    BEADMIN.BE_DAILY_SALES T34
    where  ( T34.BE_TYPE = T52.BE_TYPE and T34.SALES_DATE = T137.CALENDAR_DATE )
    group by T52.BE_TYPE, T52.DESCRIPTION, T137.YEAR, T137.QUARTER
    *) D1*
    where  ( D1.c6 = 1 )
    *) D1*
    order by c2
    +++Administrator:7e0000:7e001f:----2009/06/08 17:22:09
    -------------------- Sending query to database named DW_TESTING (id: <<15938>>):
    select D2.c2 as c1,
    D2.c3 as c2,
    D2.c1 as c3
    from
    *(select D1.c1 as c1,*
    D1.c2 as c2,
    D1.c3 as c3
    from
    *(select sum(T109.PRODUCT_SALES) as c1,*
    T137.YEAR as c2,
    T137.QUARTER as c3,
    ROW_NUMBER() OVER (PARTITION BY T137.QUARTER ORDER BY T137.QUARTER ASC) as c4
    from
    DWADMIN.DATE_MASTER T137,
    DWADMIN.DAILY_SALES T109
    where  ( T109.SALES_DATE = T137.CALENDAR_DATE )
    group by T137.YEAR, T137.QUARTER
    *) D1*
    where  ( D1.c4 = 1 )
    *) D2*
    order by c2
    It seems that query has been seperated into two, and doesn't have relationship between each others.
    However, I also tested the same situation in other environment, and it returns correct result. I found that the query hasn't been seperated into two, but one. The query is as below:
    -------------------- Sending query to database named BI (id: <<2392>>):
    WITH
    SAWITH0 AS (select D1.c1 as c1,
    D1.c2 as c2,
    D1.c3 as c3,
    D1.c4 as c4
    from
    *(select sum(T29.PRODUCT_SALES) as c1,*
    T96.DESCRIPTION as c2,
    T120.YEAR as c3,
    T120.QUARTER as c4,
    ROW_NUMBER() OVER (PARTITION BY T96.DESCRIPTION, T120.QUARTER ORDER BY T96.DESCRIPTION ASC, T120.QUARTER ASC) as c5
    from
    SIMULATION.BE_MASTER T96,
    SIMULATION.DATE_MASTER T120,
    BIEE.BE_DAILY_SALES T29
    where  ( T29.BE_TYPE = T96.BE_TYPE and T29.SALES_DATE = T120.CALENDAR_DATE )
    group by T96.DESCRIPTION, T120.YEAR, T120.QUARTER
    *) D1*
    where  ( D1.c5 = 1 ) ),
    SAWITH1 AS (select D1.c1 as c1,
    D1.c2 as c2,
    D1.c3 as c3
    from
    *(select sum(T102.PRODUCT_SALES) as c1,*
    T120.YEAR as c2,
    T120.QUARTER as c3,
    ROW_NUMBER() OVER (PARTITION BY T120.QUARTER ORDER BY T120.QUARTER ASC) as c4
    from
    SIMULATION.DATE_MASTER T120,
    SIMULATION.DAILY_SALES T102
    where  ( T102.SALES_DATE = T120.CALENDAR_DATE )
    group by T120.YEAR, T120.QUARTER
    *) D1*
    where  ( D1.c4 = 1 ) )
    select distinct case  when SAWITH0.c3 is not null then SAWITH0.c3 when SAWITH1.c2 is not null then SAWITH1.c2 end  as c1,
    case  when SAWITH0.c4 is not null then SAWITH0.c4 when SAWITH1.c3 is not null then SAWITH1.c3 end  as c2,
    SAWITH0.c2 as c3,
    SAWITH1.c1 as c4,
    SAWITH0.c1 as c5
    from
    SAWITH0 full outer join SAWITH1 On nvl(SAWITH0.c4 , 8) = nvl(SAWITH1.c3 , 8) and nvl(SAWITH0.c4 , 9) = nvl(SAWITH1.c3 , 9)
    order by c1, c2, c3
    This query returns correct result and seems reasonable.
    Assume that the setup in BI Administration is the same for both environment, why the first situation returns query that are separated?

    I have made the same remark but not with two different environment and same design.
    What can influence the construction of two queries ?
    Here some ideas :
    - if you have of course two connections pools (I assume not)
    - if in our database features (double click on the icon and choose the tab feature), full outer join is not supported
    But I have this two requirement on my laptop and I can see that I have also two sql fired.
    What you can do is to make a comparison of your two repository.
    In the administration tool, File/Compare.
    The result will be very interesting.

  • Joining two tables having no common fields using one select query

    Hi Experts,
    How to join two tables which are NOT having any field in common using only one select query?
    Your help will be appreciated.
    Thank you.

    Identify a third table (or more tables) with common fields with your two tables, or change your question either removing JOIN or removing NO COMMON FIELDS, else you wont get many responses and will be left alone in outer space, as suggested by Thomas.
    If you acturally require what you written, better execute two select and merge the two internal tables merging every record from first table with every record of second table, til no more memory is available.
    Regards,
    Raymond

  • Select query based on joining of tables from different database is taking too long

    Hi Team,
    Select query on table with millions of records is taking very long time. It took 50mins, the below query is joining on multiple table from two databases DB1.dbo.Table1 contains 100 million records and also Table3 and Table4 (of different database) might
    contain close to 1million records.
    Select T1.*
    From DB1.dbo.Table1 T1
    Join DB1.dbo.Table2 T2 on RTRIM(T1.Col3) = RTRIM(T2.Col3)
    Join Table4 CA on RTRIM(T1.Col1) + T2.Col2 = CA.Col1
    Join Table3 U on CA.Col2 = U.Col2 AND RTRIM(T2.Col2) = U.Col3
    Where U.Col4 NOT IN ('A1', 'A2', 'A3', 'A4', 'A5', 'A6','A7','A8','A9')
    And (T1.flg IS NULL OR T1.flg = 'N')
    And LTRIM(RTRIM(T2.Col2)) NOT IN ('B1','B2')
    How can i improve the performance of this query. Actual thing is update the data in Db1.dbo.table1 based on the conditions but if the select is taking close to 1hr then update will take hours together. Indexes already implemented on all the tables.
    Thanks,
    Eshwar.
    Please don't forget to Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful. It will helpful to other users.

    Thanks.
    Join Table4 CA on RTRIM(T1.Col1) + T2.Col2 = CA.Col1
    This join is not working with spaces if Rtrim is not used.
    Thanks! Eshwar.
    Please don't forget to Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful. It will helpful to other users.

  • Joining two tables with different DB

    Hi
    We have 2 sources DB2 and Oracle.
    In DB2 we have two tables which stores.
    Tbl1
    Case_no     Information1     Information2     Information3
    11112     sddf     asd     null null
    11113     asd     asd     null null
    Tbl2
    Inf     Info1     Code     Info3
    Xedy     Asdf     111     afder
    Mad     Tag     123     top
    The above tables are complex join with this condition
    Tbl1.case_no=Tbl1.case_no.
    Oracle tbl
    Code     Code_desc
    111     Very good
    123     bad
    My requirement is to join the tbl2 with Oracle tbl. Based on the codes in DB2 table I should display the Code_desc in my reports. Like this
    Case_no     Code     Code_desc
    11112     111     Very good
    11113     123     bad
    But I am getting the Cartesian result.
    Case_no     Code     Code_desc
    11112     111     Very good
    11112     123     bad
    11113     111     Very good
    11113     123     bad
    Please help to resolve.
    Regards
    MD

    Select Oracletbl and tbl2, right click on them open physical diagram, selected objects. In the physical diagram page Create a join between Oracletbl and tbl2 with the condition code=code.
    In business model create a complex join between these two. Now reload metadata/restart services check output.
    Let me know if this does not work you.

  • Joining two tables from two databases

    Hi,
    I have two tables A,B in two warehouses named CB and DB. i have to import these two tables in to RPD and join from there and generate reports in answers. will this scenario work in obiee.is it affect the performance?
    thanks
    aswin

    Hi,
    Yes it should work. just import the two db - tables into physical layer then as usual joins b/w both table. it should not have any performance issue.
    Thanks
    Deva

  • Joining two tables on different datatype key

    Hi,
    I have two two tables,
    create table table1( primkey1 double, name varchar(30))
    create table table2( primkey2 double, name varchar(30))
    Now I have to join these two table in RPD. I tried to join but i got an error.
    plz tell me the way to join these two tables.
    thank you,

    Could you please provide the error message?

  • How do you combine two or more different toolbars?

    There is wasted space on multiple toolbars that could be utilized better by moving one tool bar's items up to the empty space above. IE Norton's tool bar has 3 / 4 items on it. The Firefox tool bar above has 3 items on it: Most Visited, Getting Started and Firefox Updated with 2/3's of the bar as empty space.
    Even the menu toolbar has over half of the toolbar as empty wasted space.
    How do you do that? Thanks

    You can (temporarily) hide unneeded toolbars via "View > Toolbars"
    The bar with Most Visited and Getting Started is the Bookmarks Toolbar and if you open "View > Toolbars > Customize" then you can drag the "Bookmarks Toolbar items" item onto another toolbar (e.g. Menu bar) and hide that now empty Bookmarks toolbar.<br />
    Toolbars added by an extension can only be merged onto another toolbar if that extension supports that feature and most extensions do not.

  • How to read an APO table from excel in place using Visual Basic ?

    We have enhanced some APO reports using layouts that use excel in place with custom visual basic (VB) code. For example, the VB code can append the data with additional columns that perform specific calculations and then proceed to create pivot table reports in excel..That is working fine.
    The challenge is to see if that VB code could read specific APO tables (e.g. product master tables) to bring additional elements into excel and thus expand the report content. We know that additional fields can be added to the reports, but having the flexibility to read tables from VB could be more flexible.
    Can that be done?. If so, would it be possible using exclusively the VB code attached to the layout, i.e. no ABAP?

    Hello Anselmo,
    I am assuming you are doing this either using BeX analyzer or by reading the planning book using the RFC ActiveX component and a BAPI.
    I think it's possible to retrieve the data from the product master table. Here are my thoughts on how can this be done:
    1) You can create a generic datasource (transaction RSO2) for the product master table, connect that to a BW remotecube and use a BeX query to retrieve that values. You can then join the queries using VBA. Alternatively, you can build a muti-provider that connects your current InfoCube to the new RemoteCube and build a query from there. The multi-provider, in this case, joins the data (no more VBA).
    2) If you have already loaded your product master data into master data carrying InfoObjects then you can try the same technique as #1 but this time there is no need to create the generic datasource. You can use the InfoObjects for your master data as the InfoProviders for your query.
    3) You can try the ActiveX component from SAP which can  connect to any emote enabled function in SAP system. SAP already provided some BAPIs (check transaction BAPI for a list) which might be able to provide the data. You can also create your own function modules (be sure to make it remote enabled) using ABAP. (transaction SE37).
    Hope this helps

Maybe you are looking for

  • "If statement" problem in simple code?

    Hi, I am writing a simple homework program however am having some major problems with my "If" Statement and can not figure out why. I want my program to return a different variable if true yet it always says the statement is false. I Have it set up n

  • Please help - convert Flash8 to MX 2004

    I really need a tutorial file converted from Flash 8 to MX 2004. Can someone help? My students await.... :)

  • Chart type for Flash Chart

    Hello everybody, I'm trying to evaluate whether it's possible to use APEX for an application that I'm going to develop. Therein I want to use several charts for displaying database content. One of the charts I need is a combination of stacked charts

  • What the price about FlasCC in commerce project?

    I heard if I use alchemy, I will pay for it depend on our project income. I want to know the detail price about FlasCC, is it absolutly free?

  • CS3 fails installation - ALM to blame?

    I've been having the same frustrating time other people have trying to install CS3. Checking the logs, everything goes fine till: (Adobe) Installing ALM... (Adobe) ALM return code: 129 (Adobe) #_AdobeError_# 1603 does anyone know that these error cod