0

Is it possible to call an Oracle packageX. procedureY(a, b, c) from the conection string using SqlPlus? Something like sqlplus user/pass@tns @packageX.ProcedureY(a,b,c) without the need to log into sqlplus and then execute that procedure?

Eunito
  • 416
  • 5
  • 22
  • you can create a file add the call into the file and then call sqlplus from command line pointing to the file https://serverfault.com/a/87039/234220 – Jorge Campos Aug 20 '19 at 21:49

2 Answers2

2

Yes

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$ 
thatjeffsmith
  • 20,522
  • 6
  • 37
  • 120
  • this is basically a dupe of https://stackoverflow.com/questions/1639704/sqlplus-statement-from-command-line -- only diff is for using EXEC for a stored procedure, and I used SQLcl rather than SQLPlus – thatjeffsmith Aug 20 '19 at 22:45
0

In windows you can do it as following:

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

Cheers!!

Popeye
  • 35,427
  • 4
  • 10
  • 31