Why are some users getting "ORA-00942: table or view does not exist"?

Posted on 2008-11-14
Last Modified: 2013-12-19
Hi all,

I have a view that is working fine for most Oracle users, but a couple of them are getting "ORA-00942: table or view does not exist".  All of these users have a same common Oracle role, which includes the view in question.  A copy of the view is attached.  Any ideas what could be causing this?  I've never seen this type of thing before.




WITH spouse AS

        (SELECT gyvcsps_pidm AS pidm

               ,gyvcsps_spouse_pidm AS sp_pidm

               ,gyvname_id AS ID

               ,gyvname_addr_name AS indiv_mail_name

               ,ayvgrad_us_pref_school AS pref_us_school

               ,ayvgrad_us_pref_year AS pref_us_year

               ,ayvgrad_co_pref_school AS pref_co_school

               ,ayvgrad_co_pref_year AS pref_co_year

           FROM gyvcsps JOIN gyvname ON gyvname_pidm = gyvcsps_spouse_pidm

                LEFT JOIN ayvgrad ON ayvgrad_pidm = gyvcsps_spouse_pidm



-- Person information --

          spriden_pidm AS gyvlabl_pidm

         ,gyvname_id AS gyvlabl_id

         ,    SUBSTR (gyvname_pidm, 2, 3)

           || SUBSTR (UPPER (gyvname_last_name), 1, 3)

           || SUBSTR (gyvname_pidm, 5, 3) AS gyvlabl_mail_id

         ,gyvname_addr_name AS gyvlabl_indiv_mail_name

         ,NVL (gyvname_couple_mail_name, gyvname_addr_name) AS gyvlabl_couple_mail_name

         ,gyvname_last_name AS gyvlabl_last_name

         ,gyvhadr_atyp AS gyvlabl_homeaddr_atyp_code

         ,gyvhadr_add1 AS gyvlabl_homeaddr_line_1

         ,gyvhadr_add2 AS gyvlabl_homeaddr_line_2

         ,gyvhadr_add3 AS gyvlabl_homeaddr_line_3

         ,gyvhadr_city AS gyvlabl_homeaddr_city

         ,gyvhadr_stat AS gyvlabl_homeaddr_st_prov

         ,gyvhadr_zip AS gyvlabl_homeaddr_zip

         ,gyvhadr_natn AS gyvlabl_homeaddr_nation

         ,gyvhadr_delpt AS gyvlabl_homeaddr_delpt

         ,gyvhadr_corr_dig AS gyvlabl_homeaddr_corr_dig

         ,gyvhadr_carr_rt AS gyvlabl_homeaddr_carr_rt

         ,gyvpadr_atyp AS gyvlabl_prinaddr_atyp_code

         ,gyvpadr_add1 AS gyvlabl_prinaddr_line_1

         ,gyvpadr_add2 AS gyvlabl_prinaddr_line_2

         ,gyvpadr_add3 AS gyvlabl_prinaddr_line_3

         ,gyvpadr_city AS gyvlabl_prinaddr_city

         ,gyvpadr_stat AS gyvlabl_prinaddr_st_prov

         ,gyvpadr_zip AS gyvlabl_prinaddr_zip

         ,gyvpadr_natn AS gyvlabl_prinaddr_nation

         ,gyvpadr_delpt AS gyvlabl_prinaddr_delpt

         ,gyvpadr_corr_dig AS gyvlabl_prinaddr_corr_dig

         ,gyvpadr_carr_rt AS gyvlabl_prinaddr_carr_rt

         ,ayvgrad_us_pref_school AS gyvlabl_pref_us_school

         ,ayvgrad_us_pref_year AS gyvlabl_pref_us_year

         ,ayvgrad_co_pref_school AS gyvlabl_pref_co_school

         ,ayvgrad_co_pref_year AS gyvlabl_pref_co_year

         ,gyvemal_email AS gyvlabl_email_addr

-- Spouse information --

   ,      spouse.sp_pidm AS gyvlabl_sp_pidm

         ,spouse.ID AS gyvlabl_sp_id

         ,spouse.indiv_mail_name AS gyvlabl_sp_indiv_mail_name

         ,spouse.pref_us_school AS gyvlabl_sp_pref_us_school

         ,spouse.pref_us_year AS gyvlabl_sp_pref_us_year

         ,spouse.pref_co_school AS gyvlabl_sp_pref_co_school

         ,spouse.pref_co_year AS gyvlabl_sp_pref_co_year

     FROM SPRIDEN LEFT JOIN gyvname ON gyvname_pidm = spriden_pidm

          LEFT JOIN gyvhadr ON gyvhadr_pidm = spriden_pidm

          LEFT JOIN gyvpadr ON gyvpadr_pidm = spriden_pidm

          LEFT JOIN ayvgrad ON ayvgrad_pidm = spriden_pidm

          LEFT JOIN gyvemal ON gyvemal_pidm = spriden_pidm

          LEFT JOIN spouse ON spouse.pidm = spriden_pidm

    WHERE spriden_change_ind IS NULL

Open in new window

Question by:GLFord
    LVL 16

    Expert Comment

    How are the users accessing the view?
    Are they using application code?  Is this code pl/sql or is it sql?
    How are the users logging into the database?  Does each use have their own Oracle account (I would assume this is the case)?
    Does a different Oracle account (to the users) own the view?  Are synonyms used (public or private)?

    Author Comment

    Most users are accessing the view via ODBC-connection in MS Access.  However, I logged one of our problem users into Oracle via Toad, and the same error message comes up.
    No additional application code is being used... if I understand your question.
    In Toad, I just used a straight "select * from gyvlabl" to test the problem, and the error pops right up.
    Each user has his/her own account.  Yes, a different Oracle account owns the view, and a public synonym exists for the view.
    Hope this helps.
    LVL 16

    Accepted Solution

    The test in Toad was a good move, and thanks you have supplied all the info I was looking for.

    You say that a role has been used to grant access to the view to all users.  Has a role also been used to grant access to the tables used by the view?

    In Toad can you compare the privileges of a user for which the select * from gyvlabl query works and one for which it doesn't work.  In particular note if any table privileges been granted directly to the working user and/or if the "with grant option" has been used.

    Author Comment

    OK!!!!!!!!!  Thanks for that response!  It got me on the right track, I think.  The role has not assigned access to all of the tables that are used by the view.  Normally this should not be a problem... isn't that right?  (Assigning security to a view normally gives automatic access to the sub-views/tables?)

    Well, anyway, does that apply to the WITH statement?  One of the tables in the WITH clause did not have security granted to the role.  So, I assigned that table to the specific user id, just for testing.  And, success!  The view now runs fine for the user that was having the problem.

    Is my above analysis correct?

    Author Closing Comment

    Thanks very much for this response!  It led me to the correct answer.  As I was waiting for your follow-up to my last posting, I've indicated "Partially" to the 3 solution questions.  Nonetheless, the response gets an A!


    Author Comment

    I'll follow up for those who may read this thread in the future.
    After closing this question, I discovered that the security issue with the WITH clause in a view, is probably an Oracle 9i bug.  We are soon to migrate to 10g, and my testing in 10g shows that you do NOT have to assign security specifically to tables/views in a WITH clause query in 10g, when used within a view.  You need only assign security for the view itself.


    Featured Post

    PRTG Network Monitor: Intuitive Network Monitoring

    Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

    Join & Write a Comment

    Article by: Swadhin
    From the Oracle SQL Reference ( we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
    This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
    This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
    This video shows how to recover a database from a user managed backup

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now