在连接字符串中调用oracle过程

时间:2019-08-20 21:45:02

标签: oracle plsql sqlplus

是否可以调用Oracle packageX。使用SqlPlus从连接字符串获取procedureY(a,b,c)? 像sqlplus user / pass @ tns @ packageX.ProcedureY(a,b,c)之类的东西,无需登录sqlplus然后执行该过程?

2 个答案:

答案 0 :(得分:2)

Jeffreys-Mini:bin thatjeffsmith$ ./sql hr/oracle

SQLcl: Release 19.2.1 Production on Tue Aug 20 18:35:18 2019

Copyright (c) 1982, 2019, Oracle.  All rights reserved.

Last Successful login time: Tue Aug 20 2019 18:35:19 -04:00

Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.3.0.0.0


SQL> create or replace procedure do_nothing
  2  is
  3  begin
  4   null;
  5  end do_nothing;
  6  /

Procedure DO_NOTHING compiled

SQL> exit

Disconnected from Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.3.0.0.0
Jeffreys-Mini:bin thatjeffsmith$ ./sql hr/oracle <<EOF
> exec do_nothing()
> quit
> EOF

SQLcl: Release 19.2.1 Production on Tue Aug 20 18:36:14 2019

Copyright (c) 1982, 2019, Oracle.  All rights reserved.

Last Successful login time: Tue Aug 20 2019 18:36:15 -04:00

Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.3.0.0.0



PL/SQL procedure successfully completed.


Disconnected from Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.3.0.0.0
Jeffreys-Mini:bin thatjeffsmith$ 

答案 1 :(得分:0)

在Windows中,您可以执行以下操作:

echo execute packageX.ProcedureY(a,b,c)|user/pass@tns 

干杯!