Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

To pass in a variable and filename as parameters to a SQL file in Powershell

User_BP9OSSep 19 2022

I have a master and a sub script as PowerShell Scripts. From the Sub powerShell Script, a SQL file is called. I am looking to pass in a variable to the SQL from Master Script through the sub Script. I can see it is coming to sub script but is not coming to SQL file.
Master Script has below;

Invoke-Command -ComputerName $server_temp -FilePath E:\PshellScripts\ErrorChecks_Sub.ps1 -argumentlist $batchname 

Sub script has below;

$password = get-content E:\SQL\config\access.txt
$batch = $args[0]
& E:\Oracle\BIN\sqlplus.exe schema1/$password@env1 @E:\env1\SQL\Batch_Jobs_Error_Check.sql -Variable $batch

Batch_Jobs_Error_Check.sql has below;

set echo off
set echo off
set doc off
set pagesize 9999
set linesize 300
set feedback off
set verify off
set pause off
set flush off
set heading on
set newpage none
set termout off
set trimspool on
DEFINE batchname=&&1
spool E:\logs\Batch_Jobs_Details\Batch_Error.DTA;
select *
from batch_error where where batch_name like '&&batchname';
spool off;
exit

In the above sample, file name is hard coded. I would prefer if the filename can be dynamically assigned as theĀ &&batchname_error.dta and How can i do it inside my website Custom Lithium Ion Battery Pack Manufacturer
Could you have a look and let me know please?
Thanks, Mary

Comments
Post Details
Added on Sep 19 2022
0 comments
1,227 views