简体   繁体   中英

how to execute a oracle sql script form local machine using powershell

I have a oracle SQL script which has a select query that spools the data to a CSV file. The SQL script is saved in my local machine in some folder, how to execute this script. I also want to remove the double quotes for char in the CSV file and remove the 1st empty line in the CSV file . My first issue is how to execute the SQL script. I am new to Powershell

I am getting error as sqlplus is not recognized as a cmdlet

$mydata = invoke-sqlplus -inputfile "C:\user\script.sql" 
get-content C:\user\script.csv | select-object -skip 1
(Get-Content C:\user\script.csv_1.csv) | % {$_ -replace ‘”‘, “”} | out-file -FilePath C:\user\script.csv.csv -Force -Encoding ascii

Can you run the sqlplus command from powershell on it's own?

"sqlplus is not recognized as a cmdlet" looks to me like Windows can't find the sqlplus executable. You might need to add it to the PATH if you're going to call it straight from powershell (it's under %ORACLE_HOME%\\bin):

https://www.ibm.com/support/knowledgecenter/en/SSFUEU_7.3.0/com.ibm.swg.ba.cognos.op_installation_guide.7.3.0.doc/t_camphor_setting_environment_variables_ora.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM