How Does Oracle directly run the OS command on page 1/2?

Source: Internet
Author: User

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;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.