How Oracle runs the OS command directly (top) 1th/2 page _oracle

Source: Internet
Author: User
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
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.