【问题标题】:Azure Pipeline Powershell Task Executing SQL*Plus Always Results in SP2-0734执行 SQL*Plus 的 Azure Pipeline Powershell 任务始终导致 SP2-0734
【发布时间】:2022-06-13 13:50:04
【问题描述】:

在构建服务器上的 Azure 管道中,我想在 Powershell 脚本中执行以下操作:

  1. 在 Oracle 数据库服务器上部署最新版本的存储过程
  2. 执行这个存储过程

因此我使用 SQL*Plus 来部署和执行该过程。 出于某种原因,在#2 SQL*Plus 总是报告以下错误: SP2-0734: unknown command beginning "execute..." - rest of line ignored.

这是 Powershell 脚本:

$db_user = "user"
$db_pw = "password"
$db_conn = "server"

# 1. deploy stored procedure
sqlplus -s $db_user/$db_pw@$db_conn @Scripts\my_stored_procedure.prc

# 2. execute
"execute my_stored_procedure;" | sqlplus $db_user/$db_pw@$db_conn

它在本地工作。

举个简单的例子,这个也可以在本地工作,但不能在 Azure 管道中工作:

"select 1 from dual;" | sqlplus $db_user/$db_pw@$db_conn

SP2-0734: unknown command beginning "select ..." - rest of line ignored.

软件信息:

  • Azure DevOps 服务器 2020 更新 1.1
  • Oracle 19.11.0.0.0
  • SQL*Plus 18.3.0.0.0

【问题讨论】:

    标签: powershell azure-pipelines sqlplus


    【解决方案1】:

    作为一种解决方法,我创建了一个“通用”SQL*Plus 脚本,它只执行作为参数传递的任何 PL/SQL 代码:

    WHENEVER SQLERROR exit
    exec &&1;
    exit
    

    所以我可以在 Powershell 任务中这样称呼它:

    # 2. execute
    sqlplus -s $db_user/$db_pw@$db_conn @Scripts\execute_any_plsql.sql 'my_stored_procedure'
    

    不过,我还没有找到原始错误的原因。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-05-22
      • 2020-10-05
      • 1970-01-01
      • 2015-05-22
      • 2021-07-30
      • 2021-12-01
      • 2020-03-02
      相关资源
      最近更新 更多