【发布时间】:2018-04-23 15:55:59
【问题描述】:
我可以使用 powershell 和 sqlplus 连接到远程 oracle 数据库。此外,我还能够将数据库中执行的命令/查询的输出捕获到 powershell 变量中。 PFB 示例。
$username ="hr"
$password ="hr"
$tnsalias ="orcl"
$outputfilepath="C:\Users\Desktop"
$sqlquery=@"
set serveroutput off
set feedback off
set heading off
set echo off
select sysdate from dual;
"@
在 oracle 数据库中运行上述查询如下
$xval=$sqlquery | sqlplus -silent $username/$password@$tnsalias
echo $xval
输出将是
23-APR-18
问题是当我运行如下 PL SQL 函数时。
$sqlquery=@"
set serveroutput off
set feedback off
set heading off
set echo off
declare
x varchar2:=null;
exec x:=MYTEST_FUN('a','b');
"@
$xval 变量中没有捕获任何值,并且该函数没有运行。
如何执行函数,以便在 powershell 变量中捕获函数的返回值。
【问题讨论】:
标签: oracle powershell plsql sqlplus