Query remote table not working in PL/SQL

I have a problem that is killing me to figure out. Basically we trying to query a remote table through PL/SQL and it comes back with invalid column name for the table. But the table exists in the remote database and has the column. The query works fine from the same database outside of PL/SQL, just not in PL/SQL. I'll setup a test case below.
We have local database called DB1 and remote database called DB2. The table we are querying is called EMP.
First we create database link:
create database link DB2.WORLD connect to...
Test the link:
select ENAME from [email protected];
ENAME
SHAWN
Works fine.
Now we put this query inside a PL/SQL block:
declare
l_ename varchar2(20);
begin
select ename into l_ename from [email protected];
end;
This fails with the following error:
select ename
ERROR at line 274:
ORA-06550: line 274, column 7:
PL/SQL: ORA-00904: invalid column name
ORA-06550: line 271, column 3:
PL/SQL: SQL Statement ignored
ORA-06550: line 279, column 9:
PL/SQL: ORA-00904: invalid column name
ORA-06550: line 277, column 3:
PL/SQL: SQL Statement ignored
Now, I've tried changing how we select from the remote table, I've put the select statement in a cursor, tried creating a synonym which points to the remote table and selecting using the synonym in PL/SQL, it always returns the same error. But always works outside of PL/SQL.
Now the user we are connecting to the remote database as, has select on the EMP table, through a role, along with 30 other tables, all the other tables are able to be selected through the database link, in PL/SQL, it's just this one table.
Additionally I can go to another database, and create the same database link, and the query in PL/SQL works fine to the remote table. It's just this one table, from this one database, that doesn't work just in PL/SQL. Any ideas would be appreciated, I've exhausted everything.
Also, creating a copy of the table using "create table as select * from..." we can select from the copy of the table using PL/SQL through the database link. The problem is this is a central warehouse table, and is used my multiple applications and updated constantly, so dropping a recreating this table is a last resort.
Yes, this process did work, for over a year, then suddenly it stopped. Of course, no one made any changes to either database, that's always the case. I know the code didn't change though, it was still timestamped from a year ago.
Thanks in advance.

Could this be a variant on an old favourite, viz privileges being granted through roles. We cannot use objects in PL/SQL if our privileges are assigned through a role.
Maybe what has changed is that instead of being granted privileges on EMP@DB2 directly the privileges have been re-organised so that your user has them granted through a role.
Cheers, APC

Similar Messages

  • TRUNCATE TABLE does not work in PL/SQL - Why?

    Hey there!
    Is there any issue with truncate table not working inside an PL/SQL package?
    For example this function:
    PROCEDURE FLUSH_TABLE(vi_table_name VARCHAR2) IS
    vn_table_name VARCHAR2(30);
    BEGIN
    vn_table_name := UPPER(LTRIM(RTRIM(vi_table_name)));
    TRUNCATE TABLE vn_table_name;
    END FLUSH_TABLE;
    returns the following error msg:
    Error: PLS-00103: Encountered the symbol "TABLE" when expecting one of the following:
    := . ( @ % ;
    The symbol ":= was inserted before "TABLE" to continue.
    Line: 5926
    Text: TRUNCATE TABLE VN_TABLE_NAME;
    Can somebody explain me the problem here? In my point of view, the error msg is not quite right ;)
    Regards,
    Thomas

    > I just think the error msg is confusing
    When you looked for TRUNCATE in the PL/SQL reference you might have noticed that the PL/SQL language has no TRUNCATE keyword. The error message indicates that syntactically the code appears to be some sort of variable assignment but has an extra keyword and no assignment operator. You would get the same message for any similar string of unrecognised keywords:
    SQL> BEGIN
      2      TRUNCATE TABLE emp;
      3  END;
      4  /
        TRUNCATE TABLE emp;
    ERROR at line 2:
    ORA-06550: line 2, column 14:
    PLS-00103: Encountered the symbol "TABLE" when expecting one of the following:
    := . ( @ % ;
    The symbol ":= was inserted before "TABLE" to continue.
    SQL> BEGIN
      2      TRANSMOGRIFY TABLE emp;
      3  END;
      4  /
        TRANSMOGRIFY TABLE emp;
    ERROR at line 2:
    ORA-06550: line 2, column 18:
    PLS-00103: Encountered the symbol "TABLE" when expecting one of the following:
    := . ( @ % ;
    The symbol ":= was inserted before "TABLE" to continue.
    SQL> BEGIN
      2      MORE TEA VICAR; 
      3  END;
      4  /
        MORE TEA VICAR;
    ERROR at line 2:
    ORA-06550: line 2, column 10:
    PLS-00103: Encountered the symbol "TEA" when expecting one of the following:
    := . ( @ % ;

  • HTML not working in PL/SQL block..Help me ASAP

    declare
    l_col VARCHAR2(30) :=to_number(to_char(to_date('01-feb-2011','dd-mon-yyyy'),'dd'));
    CURSOR name_cur IS
      select name
          from   od_shift_schedule
          where   year=2011
          and    (month)=('Feb')
           and    decode(l_col,1,"01",2,"02",3,"03",4,"04",5,"05",6,"06",7,
                         "07",8,"08",9,"09",10,"10",11,"11",12,"12",13,"13",14,"14",15,"15",16,"16",17,"17",18,"18",19,"19",20,"20",
                         21,"21",22,"22",23,"23",24,"24",25,"25",26,"26",
                       27,"27",28,"28",29,"29",30,"30",31,"31")='W';
    BEGIN
      DELETE FROM nam;
      commit;
      FOR i IN name_cur
      LOOP
      dbms_output.put_line(i.name);
      htp.p('<b>Employee '||i.name||'  has been ticked.
       </b><br/>');
      EXECUTE IMMEDIATE 'insert into nam(name) values('''||i.name||''')';
      commit;
    END LOOP;
    end;Kindly help me with this
    If i'm wrong here kindly help me that how can i place a display message

    Re: HTML not working in PL/SQL block..Help me ASAP
    Using the community discussion forums for urgent issues is rude and a violation of the terms and conditions.
    http://www.oracle.com/html/terms.html
    >
    4. Use of Community Services
    Community Services are provided as a convenience to users and Oracle is not obligated to provide any technical support for, or participate in, Community Services. While Community Services may include information regarding Oracle products and services, including information from Oracle employees, they are not an official customer support channel for Oracle.
    You may use Community Services subject to the following: (a) Community Services may be used solely for your personal, informational, noncommercial purposes; (b) Content provided on or through Community Services may not be redistributed; and (c) personal data about other users may not be stored or collected except where expressly authorized by Oracle
    >
    Also please read the FAQ on how to ask questions.
    SQL and PL/SQL FAQ
    >
    2) Thread Subject line
    Give your thread a meaningful subject, not just "help please", "Query help" or "SQL". This is the SQL and PL/SQL forum. We know your question is going to be about those things, make it meaningful to the type of question so that people with the right sort of knowledge can pick it up and those without can ignore it. Never, EVER, mark your subject as "URGENT" or "ASAP"; this forum is manned by volunteers giving their own time to help and your question is never urgent or more important than their own work or than other people's questions. It may be urgent to you, but that's not forum members issue.

  • My Apple TV remote is not working.

    My Apple TV remote is not working. It was fine this morning, but now ATV is not responding to it.  It still access iTunes on my Mac so I don't think it's a battery issue. The white light flashes on ATV, but nothing happens.  I have restarted ATV several times from the mains, but no change.  Please help!

    Hey Punkmonk1,
    Thanks for the question. I understand that you are experiencing issues with your Apple TV remote. The following resource may provide a solution:
    Apple TV (2nd and 3rd generation): Resolve issues with Apple Remote
    http://support.apple.com/kb/TS5157
    Thanks,
    Matt M.

  • Remote does not work correctly after update

    Hello,
    the subject explain it already:
    After upgrading to 2.3 the apple remote does not work correctly anymore:
    I need to push the buttons twice, and than atv is only reacting sometimes.
    Any ideas?
    BR
    Frank

    Same problem here. First, I thought it was the Apple remote's battery. I replaced that and the problem persisted. I then used my digital video camera to verify that the remote was actually transmitting infrared, it was. In frustration, I tapped the buttons rapidly while pointing at the Apple TV. The Apple TV responded. The next button press it failed to respond. I tapped rapidly again and it finally responded. After many many rapid presses, while pointing directly at the Apple TV, it finally began responding to all presses. Once I'd regained control (I thought) I unpaired and re-paired the remote. Everything continued to work. At that time I also saw that I could "learn" another remote. So, I set up my Samsung TV remote. Sweet. Until the Apple TV went into screensaver mode again and I had to go through the same rapid button press sequence... with either the Apple remote or my learned Samsung remote. Conclusion, since the Apple TV will become fully responsive after the rapid button press sequence, it is certainly a software related problem.

  • Syntax highlighting not working on PL/SQL developer tool

    Hello,
    Syntax highlighting is not working on PL/SQL developer tool using the beautifier. When I go set Syntax highlighting parameters (from  EDIT>PL/SQL Developer Beautifier Options > User Interface> Editor> Syntax Highlighting ) and click apply, the changes are not reflected in SQL code in the SQL window. Other feautures in the beautifier such as Fonts, Window types are working fine.
    Please help me with this issue.
    Thanks!!
    Shreejit

    As this is not an Oracle related question (let alone Oracle SQL or PL/SQL), and as you've been given a link to the relevant website... I'll now lock this thread.

  • HT1619 my remote is not working with the new imac 27" :(

    my remote is not working with the new imac 27"    i do not know even if new imac has infrared at all , pcworld shop said yes it should work . but hey i tried everything including security setting checks

    <http://store.apple.com/us/product/MC377LL/A/apple-remote>
    "Not compatible with MacBook Pro with Retina display or iMac (Late 2012)."
    There are some USB IR receivers that allow the Apple Reomote to work with software such as Remote Buddy
    <http://www.iospirit.com/products/remotebuddy/>

  • I bought a EarPods October last year in USA, the day before yesterday the remoter can not work any more, it means by the EarPod still can lisence music but can not adjust the volume and answer the phone, can I get a new one or what can I get?

    I bought a EarPods October last year in the USA, the day before yesterday the remoter can not work any more, it means by the EarPod still can listen music but can not adjust the volume and answer the phone, can I get a new one or what can I get based on the one year product warrant?

    Now I am live in Baoding city, China, what I can do, it seems there is no apple store in my city??

  • Apple remote contra not working with Lion

    I installed Lion and my littele apple remote control does not work anymore with my mac book pro.
    Is there any solution for that?
    Thanks

    It's not working for me either.
    I know that Lion doesn't include Front Row, but the remote is not working with any other application (ex. iTunes).
    Please somebody help us!

  • 'is null' not working in dynamic sql and SQl Query component (OBPM 10gr3)

    I'm using a SQL Query component with sql like this
    'select col1, col2 from table where col3 is null'
    for some reason this does not work.
    Has anybody faced this issue? Is there a known bug with handling nulls
    Thanks

    plz post which DB version u r working with
    dont use paramters in Procedure with : sign
    Write simply the name of the Paramters like p_userid etc etc
    this might help u as well
    http://baigsorcl.blogspot.com/2010/02/get-rid-of-addtional-quotes-with-quote.html

  • Nested SQL Query in CR10 not working

    Hi
    I have a SQL query See below but crashing CR
    SELECT     ax_Staff.ax_Name, ax_Staff.ax_Reference_Number, ax_Licence.Rn_Descriptor, ax_Licence.ax_Expiry_Date, ax_Department.ax_Name AS Department
    FROM         ax_Staff INNER JOIN
                          ax_Department ON ax_Staff.ax_Department_Id = ax_Department.ax_Department_Id LEFT OUTER JOIN
                          ax_Licence ON ax_Staff.ax_Staff_Id = ax_Licence.ax_Staff_Id
    Where ax_Staff.ax_Reference_Number not in (SELECT     ax_Staff.ax_Reference_Number
    FROM         ax_Staff INNER JOIN
                          ax_Licence ON ax_Staff.ax_Staff_Id = ax_Licence.ax_Staff_Id
    WHERE     (ax_Licence.Rn_Descriptor LIKE 'Driving Licence - Rider (R)'))
    ORDER BY Department, ax_Staff.ax_Name
    The query is working on MS SQL server 2005 and giving results as I want, but I have problem to recreate this in CR.Can anybody help how to creat the report???? where Looking for list of Staff who has no Particular Licence
    Sample of the report:
    GH1: Administarion
    GH2:  Peter Brown StaffID 4442 --- THIS Group IS OK to be on the list
    GH2:     John Smith StaffID 4444 -
    THIS whole GROUP NEEDS TO BE SUPPRESED or EXCLUDED
    Details:  Driving Licence Car (C)
      Details: Driving Licence Rider (R)   --this record passed condition
      Details: Driving Licence HR  (HR)                        
    GH2:  Julia Ng StaffID 4446 --- THIS Group IS OK to be on the list
    Details:  Driving Licence C
    I have 3 tables
    Department
    Staff
    Licence

    Hi Sastry,
    Connection to the database is trough Pivotal, I have tried ODBC connection as well but same error
    The instruction at "0x005d53e0" refereced memory at "0x00000014'. The memory could not be "read".
    With ODBC I have always compilation error saying
    Query Engine Error: '42000:[Microsoft][ODBC SQL Server Driver][SQL server] Incorrect syntax near the keyword 'SELECT'. '.
    but even the simple select statment is showing the error.
    Do you think the error is with Drivers???
    Regards
    Stefan

  • SQL Query Single Row not working

    My workflow contain a Query Single row activity. I have added a where clause in Arabic which is not working. If I remove the Arabic condition its working.
    Is there something to do with the server?
    My server is windows 2008 R2 Server.
    The same workflow is running perfectly on another identical environment.
    Thanks for any valuable suggestions,
    Nith

    Hi Sastry,
    Connection to the database is trough Pivotal, I have tried ODBC connection as well but same error
    The instruction at "0x005d53e0" refereced memory at "0x00000014'. The memory could not be "read".
    With ODBC I have always compilation error saying
    Query Engine Error: '42000:[Microsoft][ODBC SQL Server Driver][SQL server] Incorrect syntax near the keyword 'SELECT'. '.
    but even the simple select statment is showing the error.
    Do you think the error is with Drivers???
    Regards
    Stefan

  • Query panel with table not working in taskflow region

    I've created an adf query panel with table(using all queriable attributes criteria) in a page fragment and at design time it's showing properly. But when inside a region in a jspx page, the search, save and reset buttons of the query panel are not rendering when i'm running the page. Please help.

    Its hard to give any solution without any information like your JDev version, what happens if you drop the query directly in the jspx page, what exception you get in console etc.
    -Arun

  • DB Adapter Re Import Table Not working (JDev 11.1.1.6.0)

    I am trying to refresh the DB adapter tables after a few columns were added. Here is what I did.
    Adapter configuration wizard --> Import Tables --> Query table --> Move the same table from Available section to Selected Section --> Click OK.
    A message pops up to confirm 'Re-Import Table'. Click Yes.
    At this point it is suppose to refresh the table and add the new columns. But when I click next, it says there are new columns available in the table. The new columns are not added to the DB adapter query.
    Has any one faced this issue? Please suggest any ideas or work around to add the columns.
    Thanks
    Ismail M.

    Re-Import table did not work for me even after lot of struggle. I tried tampering with jca, wsdl etc, re-installed the JDeveloper, tried on multiple machines but nothing worked. I finally gave up and recreated the DB adapter with 'pure sql query' option instead of tables. Re did the mappings etc. It was hard but I seem to have no other options. I will never use the table option again.
    Ismail-m

  • OR condition not working correctly in SQL

    I am adding the folling condition to a sql statement and
    AND (status_code IS NULL or status_code <> 'T'
    or (status_code IN ('A','B','C','D') and TRIM(order_type) NOT LIKE '%9999')
    or (status_code IN ('A','B','C','D') and order_type IS NOT NULL)
    or (status_code NOT IN ('A','B','C','D')))
    but the or condition work...
    if i change it too
    AND ( (status_code IN ('A','B','C','D') and order_type IS NOT NULL) )
    then this portion of the OR condition work but when I use the OR condition something weird is happening that the condition not working... and i dont see a record that meets that condition...

    Hi,
    It's not the "trim" that implies "not null", but rather the fact that:
    - "not like" operator works only on non-null values and
    - "not like" operator disregards null values.
    Consider this:
    test@ORA92>
    test@ORA92>
    test@ORA92> l
      1  with x as (
      2    select null as y from dual union all
      3    select 'a9999' from dual union all
      4    select 'bxx' from dual
      5  )
      6  select * from x
      7* where y not like '%9999'
    test@ORA92>
    test@ORA92> /
    Y
    bxx
    1 row selected.
    test@ORA92>
    test@ORA92>Here, trim function was not used, but still the first row (that had null for y) was not returned. That's because Oracle disregarded the first row for comparison and out of the next two rows, it returned the third row because it satisfied the condition.
    As for your query, do the following conditions hold true:
    1. if status_code is null      - show the row regardless of order_type
    2. if status_code <> 'T'       - show the row regardless of order_type
    3. if status_code in (a,b,c,d) and order_type is not null and order_type ends with something other than 9999 - show the row
    4. if status_code in (a,b,c,d) and order_type is null                           - do not show the row
    5. if status_code in (a,b,c,d) and order_type is not null and it ends with 9999 - do not show the row
    6. if status_code is anything other than (a,b,c,d)                              - do not show the rowpratz

Maybe you are looking for

  • Opent item management

    Frnds By some of the configuration mistake, we are not managing the <b>Check Out A/C (Bank Clearing A/c)</b> on an open item management. But now we need to keep it on opem item management, but there are already some opem items, which was created at t

  • IPhone 4s not showing up in iTunes?

    I have a windows 8 Asus laptop. Ever since I downloaded iTunes 11 my iPhone and laptop has not been connecting right. At first my laptop wouldn't even charge my phone. Then I fixed that problem with the device manager. Now my iPhone won't connect to

  • Ive deleted alot of movies off my mac but the file name of every movie still remains in all files? how do i get rid of the name? it wont let me delete :(

    i deleted alot of movies off of my mac they are gone and cannot be opened but the movie names still remain in all files in finder? it will not let me delete the names saying alias cannot be found and when i click delete alais the message only comes b

  • Loyalty Management- Finance integration

    Dear All, At the end of the day, all loyalty points are liabilities for the companies who runs loyalty program. These liabilities in terms value (for example 10 loyalty points equal to 1 USD) has to be posted to Accounts as "Amount Payable". Do we ha

  • Touchpad freezes windows 8

    Hi I have an Hp envy m4 with windows 8 preinstalled. When I try to use the multiouch gestures, the touchpad freezes and I can't move the mouse during a few seconds. I've tried everything, reinstalling drivers, updating them, etc,etc. Nothing seems to