The Oracle tutorial you are looking at is: How Oracle runs the OS command directly (ON).
In Oracle 8i, it is often the case that you want to run the operating system commands in a stored procedure. In general, this is accomplished by using Oracle Enterprise Manager to set up jobs. However, due to the lack of flexibility in the OEM operation, the parameters of the job set are fixed. In practical applications, it is often necessary to run operating system commands at any time in the SQL statement. Oracle 8i does not directly run the OS command statement, we can use the Dbms_pipe package to achieve this requirement.
Dbms_pipe by creating pipelines, you can allow at least two processes to communicate. The pipeline of Oracle has the same conceptual location as the operating system, but the implementation mechanism is different.
The following steps are implemented:
1, create a package, let's name Daemon,sql statement as follows:
/* Create Daemon Package * *
CREATE OR REPLACE PACKAGE Body daemon as
/*execute_system is the function that implements the OS command.
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 a character to the daemon pipe indicating the command
Status: = Dbms_pipe. Send_message (' daemon ', timeout);
IF Status <> 0 THEN
Raise_application_error (-20010,
' Execute_system:error while sending. Status = ' | | status);
End IF;
Current 1/2 page
12 Next read the full text