Benutzer-Werkzeuge

Webseiten-Werkzeuge


windows:powershell_sqlplus_db_abfragen

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen Revision Vorhergehende Überarbeitung
windows:powershell_sqlplus_db_abfragen [2017/12/01 17:11]
gpipperr [Auslesen]
windows:powershell_sqlplus_db_abfragen [2017/12/01 17:16] (aktuell)
gpipperr [Auslesen]
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://www.pipperr.de ) 
-# Date:   01.12.2017+# Desc:   Library for the Oracle Data import / Export  scripts 
 +# Date:   01.Dezember 2017 
 +# Site:   http://orapowershell.codeplex.com
 #============================================================================== #==============================================================================
  
 <# <#
   .NOTES   .NOTES
- Created: 01.2017 :+ Created: 11.2017 :
  .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 "0.2" -option constant Set-Variable CONFIG_VERSION "0.2" -option constant
 +
 +# 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"  -ForegroundColor "green"
 +
 +cd  $scriptpath # Set working directory if executed as job
  
 # Set enviroment # Set enviroment
 $oracle_home="C:\oracle\instantclient_12_2" $oracle_home="C:\oracle\instantclient_12_2"
 $sql_connect_string="gpi/gpi@gpidb" $sql_connect_string="gpi/gpi@gpidb"
-$data_csv="C:\s-akaby\userPWDImport.csv"+$data_csv="$scriptpath\userPWDImport.csv"
  
  
Zeile 130: Zeile 141:
 foreach( $line in $input_csv ) foreach( $line in $input_csv )
 { {
 + #debug
 + write-host $line 
  
-write-host $line  
  
 + $line="'$line'"
 + write-host $line
  
-$line="'$line'" +# Write  the data with sqlplus 12c R2! (set markup csv on quote off!)
-write-host $line +
- +
-#Write  the data with sqlplus 12c R2! (set markup csv on quote off!)+
 # 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
 "@| & "$env:ORACLE_HOME\sqlplus" -s "$sql_connect_string" "@| & "$env:ORACLE_HOME\sqlplus" -s "$sql_connect_string"
  
-$writeData=$writeData.trim()+ $writeData=$writeData.trim()
  
-#DEBUG + #DEBUG 
-write-host $writeData+ write-host $writeData
  
 } }
 +
 #write to file #write to file
-#$readData | Out-File -FilePath "$data_csv" -Append+$readData | Out-File -FilePath "$data_csv" -append
  
  
Zeile 161: Zeile 174:
  
 </code> </code>
 +
 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!
  
"Autor: Gunther Pipperr"
windows/powershell_sqlplus_db_abfragen.txt · Zuletzt geändert: 2017/12/01 17:16 von gpipperr