BravoAlphaRomeo
BravoAlphaRomeo

Reputation: 25

oracle procedure ussing Host() command

I am having a problem using host() command in oracle procedure. I have written very simple oracle code.

CREATE OR REPLACE PROCEDURE 

run_command(command_i IN VARCHAR2)

IS
  l_message  VARCHAR2 (100);

BEGIN

  l_message  := 'cmd ' || command_i;

  host(l_message); 

END run_command;

when host(l_message); is eliminated works fine.

Whats the problem and is there anyway to create a routine which uses host()?

Upvotes: 2

Views: 13062

Answers (2)

TenG
TenG

Reputation: 4004

Another clunky, but non-Java way would be to create DBMS_SCHEDULER ad-hoc EXECUTABLE job which is your HOST command (e.g. ls ), and then execute the job.

Note these run on the database server, not on your remote/local client.

Upvotes: 0

Ben
Ben

Reputation: 52883

The HOST command is only available in SQL*Plus and not from PL/SQL.

You can use Java stored procedure to call call OS commands. Oracle released a white paper on calling OS commands from within PL/SQL back in 2008 but there's plenty of other stuff out there (including Oracle Base, which is quite good)

Upvotes: 6

Related Questions