0

I am using PowerShell script to access oracle 11g's system views as SELECT COUNT (*) AS COUNT FROM v$session but I keep getting "ORA-00942: table or view does not exist"

I have created a user with sysdba privilege and all connections are a fine as I can even query other schemas without errors, but I only get error when I access any system views. can anyone tell me what I am doing wrong?

I also gave permission as "GRANT SELECT on v_$session TO mynewuser even tho I know its not needed if the user has sysdba.

closed as off-topic by Colin 't Hart, Paul White Sep 10 '15 at 18:27

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Too localized - this could be because your code has a typo, basic error, or is not relevant to most of our audience. Consider revising your question so that it appeals to a broader audience. As it stands, the question is unlikely to help other users (regarding typo questions, see this meta question for background)." – Colin 't Hart, Paul White
If this question can be reworded to fit the rules in the help center, please edit the question.

1

What powershell syntax are you using?

If you do not enclose the select between single quotes, Powershell will treat it like a variable. If that's the problem, please try:

$command.CommandText = 'SELECT COUNT (*) AS COUNT FROM v$session'
-1

You need to grant the DBA role to the user. SYSDBA does not give you the right to these objects.

  • yes I also given DBA role to this new user and still no luck – leo77 Aug 11 '15 at 11:14
  • Can you access the v$session view with that user from another tool? Also, when you want to use the v_$session then you must add the owner: sys.v_$session. – Marco Aug 11 '15 at 11:26
  • yes I can connect using TOAD with that user and access it with out any problem, I also tried with sys. – leo77 Aug 11 '15 at 11:28
  • Means that the problem most likely comes from the powershell. I cannot help you with that. I am more a Linux guy. – Marco Aug 11 '15 at 11:37

Not the answer you're looking for? Browse other questions tagged or ask your own question.