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

Source: Internet
Author: User
How Does Oracle directly run the OS command (on)

How Does Oracle directly run the OS command (on)

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 directly run the OS command. We can use the DBMS_PIPE package to implement this requirement.

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;

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.