The Oracle tutorial is: how to directly run the OS command (on) in Oracle ).
In Oracle 8i, operating system commands are often run during the storage process. Generally, Oracle Enterprise Manager can be used to set jobs. However, due to the lack of flexibility in the setup of OEM jobs, the set job parameters are fixed. In practical applications, operating system commands must be run in SQL statements at any time. Oracle 8i does not have a statement to directly run the OS command. We can use dbms_pipeProgramPackage.
Dbms_pipe creates an MPS queue to allow at least two processes to communicate with each other. The Oracle pipeline and the operating system pipeline have the same concept, but the implementation mechanism is different.
The following describes the implementation steps:
1. Create a package named daemon. The SQL statement is as follows:
/* Create a daemon package */
Create or replace package body daemon
/* Execute_system is a function used to run OS commands */
Function execute_system (command varchar2,
Timeout number default 10)
Return number is
Status Number;
result varchar2 (20);
command_code number;
pipe_name varchar2 (30);
begin
pipe_name: = dbms_pipe.unique_session_name;
dbms_pipe.pack_message ('system');
dbms_pipe.pack_message (pipe_name);
dbms_pipe.pack_message (command );
/* Send the character indicating the command to the daemon Pipeline */
Status: = dbms_pipe.send_message ('daemon', timeout );
If status <> 0 then
raise_application_error (-20010,
'execute _ system: Error while sending. status = '| status);
end if;