Re: ORA-00942: table or view does not exist for v$session.

From: Eric <eric_at_deptj.eu>
Date: Fri, 12 Feb 2016 16:11:15 +0100
Message-ID: <slrnnbrtgj.kh9.eric_at_bruno.deptj.eu>


On 2016-02-12, ramana910140_at_gmail.com <ramana910140_at_gmail.com> wrote:
> Hi Eugene,
>
> while i am running "SELECT COUNT(*) cnt,status FROM v$session GROUP BY status"
> it is working fine, fetching the records
>
> but same thing iam using in a procedure like below
> FOR i IN
> ( SELECT COUNT(*) cnt,status FROM SYS.v$session GROUP BY status
> )
> LOOP
> ---
> END
>
> but here i am getting the Same error Table does not Exist
>
> can you please reply on this plese
>
> and is there any possiblities to use this query resultset in my procedure?

Well, you are responding to a five-and-a-half year old message, which rather reduces you chance of getting a response from Eugene!

Anyway, the solution is already in his message:

    Have your DBA grant an explicit SELECT privilege on the SYS.V_$SESSION     table and see if that works.

This is because when it works for you interactively your user presumably has some roles granted which allow you to see V$SESSION, but inside a procedure roles are not enabled, so you can't see it, hence the need for an explicit grant. BTW, note the underscore in the name for the grant - this is _necessary_.

One more thing, putting something like "can you please reply on this plese" in message makes you sound impatient no matter how many different ways you spell "please", and discourages many people from responding.

Eric

-- 
ms fnd in a lbry
Received on Fri Feb 12 2016 - 16:11:15 CET

Original text of this message