Query from different schema

I am using oracle sqldeveloper. I am trying to run a query on a different schema. Whenever I run the following:
Select *
From SchemaA.Users us
Order by US.last_name asc
I get the following error:
US.last_name: invalid identifier.
I would get the same error when I place a where clause on the end as well. I am sure it is an error in syntax. Nonetheless, I am not sure how to correctly write the query. Any help on this topic would be great. Thanks in advance.

Hi,
NewApexCoder wrote:
I am using oracle sqldeveloper. I am trying to run a query on a different schema. Whenever I run the following:
Select *  
From SchemaA.Users us  
Order by US.last_name asc 
I get the following error:
US.last_name: invalid identifier.
I would get the same error when I place a where clause on the end as well. I am sure it is an error in syntax. Nonetheless, I am not sure how to correctly write the query. Any help on this topic would be great. Thanks in advance.
I don't see anything obviously wrong with the syntax, or ianything else in that code.  You didn't post CREATE TABLE and INSERT statements for the USERS table, so I can't actually test it, but I can run very similar queries, like this:
SELECT    *
FROM      scott.dept  sd
ORDER BY  sd.dname  ASC
Are you sure there's a column called LAST_NAME in the SCHEMAA.USERS table?  If I spell DNAME wrong, then the query above gets the "invalid identifier"  error, just like yours.
USERS is an Oracle keyword, so it's not a very good table name.  That's almost certainly not what's causing this problem, however.

Similar Messages

  • Sinlge select query in different schemas for same table(Indentical Structu)

    Scenario :
    Table XYZ is created in Schema A
    After an year, the old data from the previous year would be moved to different schema. However in the other schema the same table name would be used.
    For eg
    Schema A contains table XYZ with data of 2012 yr
    Schema B contains table XYZ with data of 2011 yr
    Table XYZ in both the schemas have identical structure.
    So can we fire a single select query to read the data from both the tables in effective way.
    Eg select * from XYZ where date range between 15-Oct-2011 to 15-Mar-2012.
    However the data resides in 2 different schema altogether.

    Thanks for the reply
    Creating an view is an option.
    But my problem, there is ORM layer(either Hibernate or Eclipse Top Link) between the application and the database.
    So the queries would be formed by the ORM layer and are not hand generated.
    So i cannot use view.
    So is there any option that would allow me to use single query on different schema's ?

  • Accessing tables from different schema in CDS and AMDP

    Hi All,
    We are working on a HANA system which has several schema replicated from SAP R/3/Non SAP systems. We have BW 7.4 SP9 deployed on the same system and accessing the HANA views using latest BW virtual objects such as Open ODS , Composite providers etc.
    We are also using the BW system for few ABAP based data processing developments. We are currently accessing HANA views in ABAP programs by creating dictionary views based on external HANA views.
    We would like to however use recent possibilities of CDS and AMDP for better life cycle management of ABAP based solutions. The open SAP course on this subject was of very good help. Thanks a lot "open SAP team" for that. I would however have few open questions,
    As I understand AMDP gives us full flexibility of writing sql procedures within ABAP development environment, but can we access tables from different schema into AMDP code. If yes, then sample code would help.
    If the answer of first question is yes, then how do we manage transports between development and production systems where the schema names would be different. Currently in open HANA developments, such transport is manged using Schema mapping.
    Can I also use different schema tables in CDS views.
    We are updating few tables in ABAP dictionary after applying processing logic in ABAP program as detailed in step 1. With the new approach using AMDP, can we directly update database schema tables which will give us an optimization advantage.
    New ABAP HANA program interfaces are quite promising and we would like to use them to optimize many data intensive applications.
    Thanks & Regards,
    Anil

    Hi Anil,
    I can only answer 1. and 2. (and would be interested into 3. as well):
    1.
    Yes you can access tables from a different schema and also HANA views. In this case no 'using' is needed.
    Examples:
        RESULT = SELECT
        FROM
              "SAP_ECC"."T441V" AS t,
              "_SYS_BIC"."tmp.package/AFPO" AS a.
        WHERE ...
    2. In this case, if you need schema mapping: You could use HANA (projection) views which just forward to a different schema, also see example.
    Best regards,
    Christoph

  • 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.

  • Select query from 2 schema & database

    Hi,
    what privileges should i give to execute select query from 2 schema & database in oracle
    thanks

    Hi,
    not so clear, if you are looking for this
    -- for other schema access
    GRANT SELECT ON <scheman_name>.<table_name> TO <schema_name>;
    or create the synonym
    --for other database access you need to create db link                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Copying a query from different user group

    masters,
    is it possible to copy a query from different user group?
    if so please tell me how
    thnks!

    The query made from SQVI is only intended for individual use. It cannot be transported and there is no concept of Global/Standard area. To be able to transport or share the query to other users is by converting it to SAP Query wherein the source of data will also be converted to an Infoset. Remember that is done in the Standard query area. To do this, go to SQVI-> click SAP Query then go to menu Query -> Convert Quickviews... Select your Quickview queries and provide and infoset name.

  • Analytic View with tables from different schema

    Hi,
    I'm curious if I make something wrong or if this is not possible:
    I want to use two tables each in a different schema. I can drop them into the DataFoundation, can connect them, assign them some measure. But activation fails due to insufficient privileges. When I use the tables from the same schema activation works well. With the insufficient privileges I would guess HANA cannot create a View (failed with the statement CREATE COLUMN_VIEW "_SYS_BIC"."USER/ANALYTIC_VIEW_NAME"....).
    Since I tried the same assignment with the System-User and failed I wonder what kind of permissions are required. Or is this generally not allowed (resp. prohibited)?
    If not allowed, could somebody give me a hint, why its not possible?
    If it is possible, what kind of rights are required to get it working?
    roland

    Hm', I have allowed SYS_REPO the rights to the table and was able to activate the view. But now I have the problem, that the DataPreview is not working (again insufficient privileges). What user has to have additional permissions for the JDBC-query?
    Do I have to take care more on the privileges for other things?

  • To call from different schemas

    Good Morning Everyone,
    Is it possible to call different environments DB?
    We have test1 and test2 environments. There are 2 tables contact and users table in both environments.
    T.Contact T.User
    T1.User
    The contact is reference table and have to update user table ID.
    If we had a same DB, we could use like this: assumptions.
    UPDATE T.Contact
    SET USER_ID IN (SELECT USER_ID FROM T.User A, T.Contact B , T1.User C
    WHERE
    A.LNAME = C.LNAME
    AND A.FNAME = C.FNAME
    AND A. USER_ID = B.USER_ID
    If you have expereinces in this issue, please share with us.
    Thanks
    S!G

    Answers:
    If different environments mean different schemas, then YES
    If different environments mean different connects from client side, then NO.
    However: You can make them into one "environment" by using database links as it had been mentioned before.
    Furthermore: Your query is not good.
    It is syntactically wrong and it is logically wrong.
    It uses the Table CONTACT two times and therefore would end up in updating all rows, even if the sytax problem is solved.
    A better approach could look like this, but there is still room for optimization:
    UPDATE T.Contact u
    SET u.status = 'is a remote user'
    WHERE u.USER_ID IN (SELECT A.USER_ID
                   FROM T.User A
                   JOIN T1.User C on A.LNAME = C.LNAME
                                     AND A.FNAME = C.FNAME)

  • Read tables from different schemas in oracle

    Hi, I'm trying to write a code to run a query to get data from an Oracle server, the problem is that the query refers to multiple tables in multiple schemas... the regular way to do it in oracle (SCHEMANAME.TABLENAME) does not work in excel vba query and
    I cant find a way to so, any help will be really appreciated, below a sample code with one table from WWPP schema.....
    Const DB As String = "Driver={Microsoft ODBC for Oracle};" & _
                         "CONNECTSTRING=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=1526))(CONNECT_DATA=(SERVICE_NAME=MyName)));" & _
                         "Uid=MyID;Pwd=MyPwd*;"
    Sub test()
        Dim cnt As ADODB.Connection, rst As ADODB.Recordset
        Set cnt = New ADODB.Connection
        Set rst = New ADODB.Recordset
        cnt.Open DB
        (I also tried this but didn't work) -> cnt.Execute "ALTER SESSION SET CURRENT_SCHEMA=WWPP"
        rst.Open "SELECT * FROM WWPP.SO_LIFE_CYCLE_BACKLOG_RP", cnt, adOpenDynamic, 2
        If rst.EOF = False Then
            Sheet1.Cells(2, 2).Select
            Selection.CopyFromRecordset rst
        End If
        rst.Close
    End Sub
    Oscar Marquez

    1) Posting the error number (i.e. ORA-00942) in addition to the error message is often quite helpful since that's generally far easier to look up and far less likely to get confused in translation.
    2) Are you using an invoker's rights stored procedure? Or a definer's rights stored procedure? If you're not sure, the default is definer's rights.
    3) How has YFS been granted access to the Y_PS table? My hunch is that it was granted access via a role, not via a direct grant. Privileges granted through a role would be available for ad hoc SQL queries, but those privileges are not available to a definer's rights stored procedure. A definer's rights stored procedure only has access to the privileges granted directly to the owner.
    If my hunch is correct, you'd either have to directly grant YFS access to the table(s) it needs to access in other schemas or you'd need to make the stored procedure use invoker's rights, which may have ripple effects down the line if users other than YFS are going to be running the procedure.
    Justin

  • Can we join table from different schema?

    Hi
    All,
    I have a SYS schema and MED schema. Now, I want to join DBA_USERS tables from SYS schema to EMPLOYEE table from MED schema to get an username. i am using following query but it's not working.
    select username,empl_userid,empl_nm_lst,empl_nm_fst from sys.dba_users db, med.employee emp where db.username = emp.empl_userid;
    Thanks,
    vishal

    g8 it is working now I just modify my query to make user name in upper case and then compare..
    select username,empl_userid,empl_nm_lst,empl_nm_fst from sys.dba_users db, med.employee emp where db.username = upper(emp.empl_userid);
    before that it was returning nothing..
    thanks for your help ... awesome..
    vishal
    Edited by: vishal patel on Sep 29, 2008 2:39 PM
    Edited by: vishal patel on Sep 29, 2008 2:40 PM

  • Provide a way to distinguish same object from different schema

    Hi there,
    When the same object is present in different schema and loaded into sql developer, there no chance to distinguish at first sight to which connection (or schema) the object belong.
    Example :
    DbConnection1 -> tables -> my_table
    DbConnection2 -> tables -> my_table
    when both are "loaded" (visible as a tab on the right side of sql developer)...i have no chance to find visually which "my_table" tab belong to "DbConnection1" or to "DbConnection2"...
    Regards,
    Pierre-Yves

    Thanks.
    A good idea would be to provide an option in "Preferences" to activate (or not) the display of the connection info directly in the tab name (my_table@dbConnection1).
    Regards,
    Pierre-Yves

  • How to execute the query from different blocks in Forms

    Hi,
    Curently I have a case where I need to execute the query from some other block. I used
    l_curr_item VARCHAR2(62) := :SYSTEM.CURSOR_ITEM;
    Go_Block ('BLOCK2');
    Execute_Query;
    Go_Item(l_curr_item);
    This works fine , but as I am using Go_Block it does some other activities related to that block, which I dont want them to get executed.
    So can any one please suggest me how I can call the query alone without using the Go_Block .
    Thank you.

    you can set global variable and filter for this variable in the triggers of blocks the actions then you avoid the code of trigger and you can use go_block

  • Select Into statement in db function - query from granted schema table

    problem with "select into" in db function in 10.2
    There are two schemas. 'mdbdev' is the master database and 'devusr' is granted SELECT table access to execute queries in mdbdev schema.
    with devusr, in SQL, I'm able to execute the following query
    select wm_concat(strConcatedCountryList)
    from (select country_name as strConcatedCountryList from mdbdev.country_master mdbcm
    where mdbcm.country_ship_status = <param?>
    order by country_name)
    but when I use the same query in function/procedure with "select into", the compilation failed with error *"table or view does not exist"*
    FUNCTION GETCOUNTRYLISTTOSHIP (SHIP_STATUS IN NUMBER)
    RETURN VARCHAR2
    IS
    var2CountryList VARCHAR2(1000);
    BEGIN
    select wm_concat(strConcatedCountryList) INTO var2CountryList
    from (select country_name as strConcatedCountryList from mdbdev.country_master mdbcm
    where mdbcm.country_ship_status = <value of SHIP_STATUS>
    order by country_name);
    return var2CountryList;
    END;
    Please advise/help/hint :)

    David, Justine, Thank you. The facts from this forum post helped a lot to get the solution.
    The query helped a lot (select * from all_tab_privs_recd where owner = 'MDBDEV' and table_name = 'COUNTRY_MASTER").
    there was a grant using ???(donno wht DBA said) and no direct SELECT grant on that country_master to "devusr". grant command executed. Now, it works :)

  • Calling procedure dynamically, from different schema, permissions issue

    Hi,
    I have a 'master_user' schema that needs to run DDL on a 'secondary_user' schema.
    There appears to be some kind of permissions subtlety that I'm missing. Here are the simplified steps to create, test and troubleshoot:
    Secondary schema has a procedure defined:
    -- Run as SYSTEM (at build time)
    CREATE OR REPLACE PROCEDURE secondary_user.execute_immediate(p_sql_statement IN VARCHAR2)
    IS
    BEGIN
        EXECUTE IMMEDIATE p_sql_statement;
    END;
    GRANT EXECUTE ON secondary_user.execute_immediate TO master_user;
    I then want to call this procedure from master_user to execute DDL dynamically in secondary_user.
    - Run as master_user
    BEGIN
        EXECUTE IMMEDIATE ' BEGIN secondary_user.execute_immediate(''DROP TABLE test1''); END;';
    END;
    ERROR at line 1:
    ORA-00942: table or view does not exist
    ORA-06512: at SECONDARY_USER.EXECUTE_IMMEDIATE", line 5
    ORA-06512: at line 1
    ORA-06512: at line 2
    TROUBLESHOOTING SO FAR:
    Now I can call this procedure directly:
    -- As master_user
    EXEC secondary_user.execute_immediate('drop table test1')
    PL/SQL procedure successfully completed.
    I can call the wrapped procedure as different users:
    -- As secondary_user
    BEGIN
        EXECUTE IMMEDIATE ' BEGIN secondary_user.execute_immediate(''DROP TABLE test1''); END;';
    END;
    PL/SQL procedure successfully completed.
    -- As SYSTEM
    BEGIN
        EXECUTE IMMEDIATE ' BEGIN secondary_user.execute_immediate(''DROP TABLE test1''); END;';
    END;
    PL/SQL procedure successfully completed.
    Can you shed any light on this behaviour? The master_user clearly has permission to run the procedure, but it cannot see it from within an anonymous block. However SYSTEM can so what permission does SYSTEM have that master_user does not?
    Much appreciated,
    Si

    Something doesn't add up:
    SCOTT@orcl > create user secondary_user
      2  identified by secondary_user
      3  default tablespace users
      4  quota unlimited on users
      5  /
    User created.
    SCOTT@orcl > grant create session to secondary_user
      2  /
    Grant succeeded.
    SCOTT@orcl > create user master_user
      2  identified by master_user
      3  default tablespace users
      4  quota unlimited on users
      5  /
    User created.
    SCOTT@orcl > grant create session to master_user
      2  /
    Grant succeeded.
    SCOTT@orcl > CREATE OR REPLACE PROCEDURE secondary_user.execute_immediate(p_sql_statement IN VARCHAR2)
      2
      3  IS
      4
      5  BEGIN
      6
      7      EXECUTE IMMEDIATE p_sql_statement;
      8
      9  END;
    10
    11  /
    Procedure created.
    SCOTT@orcl > GRANT EXECUTE ON secondary_user.execute_immediate TO master_user;
    Grant succeeded.
    SCOTT@orcl >
    SCOTT@orcl > create table secondary_user.test1(n number)
      2  /
    Table created.
    SCOTT@orcl > connect master_user@orcl
    Enter password:
    Connected.
    MASTER_USER@orcl > BEGIN
      2
      3      EXECUTE IMMEDIATE ' BEGIN secondary_user.execute_immediate(''DROP TABLE test1''); END;';
      4
      5  END;
      6
      7  /
    PL/SQL procedure successfully completed.
    MASTER_USER@orcl >
    Make sure table secondary_user.test1 exists when you run SP. And, as you can see, neither secondary_user nor master_user have any privs besides create session.
    SY.

  • Slow response time on query from one schema to another

    I've got two separate databases (one test, the other production). The schemas are pretty much identical and contain the same data. This particular query is executed from .NET (SQL text command, not SP) and takes about 3 seconds when performed against my test db, but takes anywhere from 45 seconds to 5 minutes on the production system. I've exceuted the same statement using Aquadata studio and get the same response times. I didn't build the queries or the schemas, nor do I manage the database servers. But I am responsible for making this work now. These queries have been working in the past, but recently have been changed. I am able to speed this one up with some sql changes, but the others I'm not sure about. I've checked and production db has indexes on the fields I'm querying while the test db does not. I would expect test to be slower, but it's not. Any ideas that I could try. On Monday I'll ask our server admins to check out the server end of it, and see if they need to reboot or something. In the meantime, I'm going to work to revamp the SQL.
    Any ideas you can provide would be much appreciated.
    Sincerely,
    Zam

    when your query takes long...
    When your query takes too long ...

Maybe you are looking for

  • Table name for ( ECR )

    Dear Guru's can u provide me table name where i can get object no.  for the corresponding change number. ( ECR no. ) . I want to check the status of change number by puting the object no. in Table " Jest ". Status means ECR release, ECO release etc.

  • ACE4710 A3(2.) High resource allocation denied count

    We have 2 x ACE4710 appliance running in redundant mode, with LB1 hosting an active Context1 and a hot standby Context2, LB2 running a hot standby Context1 and active context2 - essentially to spread the load across the 2 boxes. they'd been running w

  • RE: SEARCH Task 4 & 5 in the Toolbox Tutorial 11.5.10

    Hi, I'm following the Toolbox Tutorial 11.5.10 but I'm using my own workspace and project, thus different data. I get the following error: Message was edited by: user552030

  • StopMediaTransmission rx 92, successful 46, failed 92 -- seeking a fix for this failed message?

    Profile Identifier: 2, Service Type: Conferencing TCP packets rx 2549, tx 2439 Unsupported pkts rx 0, Unrecognized pkts rx 0 Register tx 1, successful 1, rejected 0, failed 0 Unregister tx 0, successful 0 KeepAlive tx 2322, successful 2322, failed 0

  • Import history of a request

    Hi How can I find out who has imported a request in Production system? I have created a request in Development system and moved it to import queue of the Production system. there is no automatic import set. But I found somebody have imported my reque