Within an Azure pipeline on the build server I want to do the following things in a Powershell script:
Therefore I use SQL*Plus to deploy and execute the procedure.
For some reason at #2 SQL*Plus always reports the following error:
SP2-0734: unknown command beginning "execute..." - rest of line ignored.
This is the Powershell script:
$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
It works locally.
For a minimal example, this one also works locally but not in the Azure pipeline:
"select 1 from dual;" | sqlplus $db_user/$db_pw@$db_conn
SP2-0734: unknown command beginning "select ..." - rest of line ignored.
Software information:
As a workaround I created a "generic" SQL*Plus script which simply executes any PL/SQL code passed as a parameter:
WHENEVER SQLERROR exit
exec &&1;
exit
So I can call it like this in the Powershell task:
# 2. execute
sqlplus -s $db_user/$db_pw@$db_conn @Scripts\execute_any_plsql.sql 'my_stored_procedure'
I haven't found the cause for the original error, though.