Database Reference
In-Depth Information
if (Test-Path($outputFilename)) {
"Removing old copy of $outputFilename"
Remove-Item $outputFilename -Force
}
"Loading ODP.NET 2x"; $asm = Load-ODP -version 2 -passthru
"Loaded {0}" -f $asm.FullName
"Reading SQL from $sqlFilename"
$sql = (Get-Content $sqlFilename -EV err) | Out-String
if ($err) {
Write-Warning "SQL read failed; bailing"; throw $err
}
$sql
"Reading connection string from $configFile"
$connectString = (Get-ConfigConnectString $configFile
AppConnect)
"Connecting with $connectString"
$conn = Connect-ODP $connectString
try {
"Running SQL using threshold of $commissionThreshold"
$dt = Get-ODPDataTable $conn $sql @{ 'commission_
threshold' = $commissionThreshold; }
"Retrieved {0} record(s):" -f $dt.Rows.Count
$dt | ft -auto
"Exporting data to $outputFilename"
$dt | Export-CSV -NoTypeInformation $outputFilename
$dt.Dispose()
}
catch [System.Exception] {
throw "Failed to run SQL: " + $_.Exception.ToString()
}
finally {
"Closing connection"
$conn.Close(); $conn.Dispose()
}
}
 
Search WWH ::




Custom Search