windows:powershell_sqlplus_db_abfragen
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen RevisionVorhergehende Überarbeitung | |||
windows:powershell_sqlplus_db_abfragen [2017/12/01 17:11] – [Auslesen] gpipperr | windows:powershell_sqlplus_db_abfragen [2017/12/01 17:16] (aktuell) – [Auslesen] gpipperr | ||
---|---|---|---|
Zeile 87: | Zeile 87: | ||
<code powershell getData.ps1> | <code powershell getData.ps1> | ||
- | |||
# | # | ||
- | # Desc: write data to the oracle database with sqlplus | + | # Author: Gunther Pippèrr ( http:// |
- | # Date: 01.12.2017 | + | # Desc: Library for the Oracle Data import / Export |
+ | # Date: 01.Dezember | ||
+ | # Site: | ||
# | # | ||
<# | <# | ||
| | ||
- | Created: | + | Created: |
.SYNOPSIS | .SYNOPSIS | ||
- | write data to the oracle database with sqlplus | + | read data to the oracle database with sqlplus |
.DESCRIPTION | .DESCRIPTION | ||
- | write data to the oracle database with sqlplus | + | read data to the oracle database with sqlplus |
.COMPONENT | .COMPONENT | ||
Oracle PS Helper Scripts | Oracle PS Helper Scripts | ||
Zeile 108: | Zeile 109: | ||
# | # | ||
Set-Variable CONFIG_VERSION " | Set-Variable CONFIG_VERSION " | ||
+ | |||
+ | # Rember the script path to find the csv | ||
+ | $Invocation = (Get-Variable MyInvocation -Scope 0).Value | ||
+ | $scriptpath=Split-Path $Invocation.MyCommand.Path | ||
+ | |||
+ | $starttime=get-date | ||
+ | |||
+ | write-host "Info -- start the Script in the path $scriptpath at $starttime" | ||
+ | |||
+ | cd $scriptpath # Set working directory if executed as job | ||
# Set enviroment | # Set enviroment | ||
$oracle_home=" | $oracle_home=" | ||
$sql_connect_string=" | $sql_connect_string=" | ||
- | $data_csv=" | + | $data_csv=" |
Zeile 130: | Zeile 141: | ||
foreach( $line in $input_csv ) | foreach( $line in $input_csv ) | ||
{ | { | ||
+ | #debug | ||
+ | write-host $line | ||
- | write-host $line | ||
+ | $line="' | ||
+ | write-host $line | ||
- | $line="' | + | # Write the data with sqlplus 12c R2! (set markup csv on quote off!) |
- | write-host $line | + | |
- | + | ||
- | # | + | |
# for all other use the older format settings! | # for all other use the older format settings! | ||
+ | # must be on start of line!! | ||
$writeData=@" | $writeData=@" | ||
set pagesize 0 | set pagesize 0 | ||
Zeile 144: | Zeile 156: | ||
set markup csv on quote off | set markup csv on quote off | ||
set heading off | set heading off | ||
- | select $line as val1, sysdate as val2 from dual; | + | select $line as val1, sysdate as val2,sysdate+1 as val3 from dual; |
quit | quit | ||
"@| & " | "@| & " | ||
- | $writeData=$writeData.trim() | + | $writeData=$writeData.trim() |
- | #DEBUG | + | #DEBUG |
- | write-host $writeData | + | write-host $writeData |
} | } | ||
+ | |||
#write to file | #write to file | ||
- | #$readData | Out-File -FilePath " | + | $readData | Out-File -FilePath " |
Zeile 161: | Zeile 174: | ||
</ | </ | ||
+ | |||
Das Password sollte natürlich hier nicht in Klarschrift in einem produktiven Skript stehen! | Das Password sollte natürlich hier nicht in Klarschrift in einem produktiven Skript stehen! | ||
windows/powershell_sqlplus_db_abfragen.txt · Zuletzt geändert: 2017/12/01 17:16 von gpipperr