The Multifunctioning DBA

Nov 21 2011   4:10PM GMT

Query Oracle with Powershell

Colin Smith Colin Smith Profile: Colin Smith


I have a small project that I am working on and it requires that I pull data from Oracle from within a Powershell script. This is not something that is fun but it can be done and it is not really that difficult to get the data out of Oracle, it is dealing with the data once you have the data out.

$query = "select * from table;"
$query | sqlplus username/password@SID

That will push the data back for you but it is ugly and you are going to have to parse that data somehow to get it into a format that is useful to you. It all depends on what the query is and how you need the data. For me I ended up having to break my query down into two queries in order to deal with the data and get the output that I was after. The problem is that it returns as a giant string and the sting is not really formatted in any useful way. So you may have to be creative in order to get what you need but it can be done.

 Comment on this Post

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: