sql - select from v$lock in powershell -


i try run fragment (as sys/ sysdba):

    try{ $conn = new-object data.odbc.odbcconnection $conn.connectionstring= $connectionstring $conn.open(); $q =  "select * v$lock ";     $reader = (new-object data.odbc.odbccommand($q,$conn)).executescalar(); write-host $reader   $conn.close() } catch {   write-host ( $_.exception.message ) } 

on toad can select v$lock, in script have ansver like

    exception calling "executescalar" "0" argument(s): "error [42s02] [oracle][odbc][ora]ora-00942: table or view not exist 

where cause of problem?

powershell thinks referring variable $lock on statement instead of string literial v$lock:

$q =  "select * v$lock "; 

you got either escape $ symbol backtick ` or use single quotes don't expand variables. what's more, idiomatic powershell doesn't use semicolon statement terminators. so,

$q =  'select * v$lock '  # single quotes don't expand variables $q =  "select * v`$lock " # backtick escapes $ not variable symbol 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -