The Multifunctioning DBA

Nov 21 2011   4:10PM GMT

Query Oracle with Powershell



Posted by: Colin Smith
Tags:
Oracle
Powershell

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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

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: