Home » SQL & PL/SQL » Client Tools » Output of a DB Query as Email using Powershell (Oracle Database Enterprise Server,, Windows 2008 Release 2)
Output of a DB Query as Email using Powershell [message #547549] Wed, 14 March 2012 12:11
Messages: 197
Registered: March 2006
Senior Member
Hello All,

Currently i am writing a code using powershell to query from Oracle Database 11g Release 2.

I got a code by searching google.

function Get-OLEDBData ($connectstring, $sql) {
$OLEDBConn = New-Object System.Data.OleDb.OleDbConnection($connectstring)
$readcmd = New-Object system.Data.OleDb.OleDbCommand($sql,$OLEDBConn)
$readcmd.CommandTimeout = '300'
$da = New-Object system.Data.OleDb.OleDbDataAdapter($readcmd)
$dt = New-Object system.Data.datatable
return $dt

$connString = "password=assword;User ID=SYSTEM;Data Source=XE;Provider=OraOLEDB.Oracle"
./Get-OLEDBData $connString $qry

is it required to create a DataSource using odbc32.cpl which points to the Oracle Database.

Also if you have a code for emailing the output of a query please post.

Salih KM
Previous Topic: Alternate solution to DB link
Next Topic: SQL tracker problem monitoring w3wp.exe
Goto Forum:

Current Time: Sat Sep 26 18:46:42 CDT 2020