在Oracle
DBMS_PIPE通過創建管道
下面介紹實現具體步驟:
/*創建daemon程序包*/
CREATE OR REPLACE PACKAGE BODY daemon AS
/*execute_system是實現運行os命令的函數*/
FUNCTION execute_system(command VARCHAR
timeout NUMBER DEFAULT
RETURN NUMBER IS
status NUMBER
result VARCHAR
command_code NUMBER
pipe_name VARCHAR
BEGIN
pipe_name := DBMS_PIPE
DBMS_PIPE
DBMS_PIPE
DBMS_PIPE
/*向daemon管道發送表示命令的字符*/
status := DBMS_PIPE
IF status <>
RAISE_APPLICATION_ERROR(
END IF
status := DBMS_PIPE
IF status <>
RAISE_APPLICATION_ERROR(
Status =
END IF
/*獲取返回結果*/
DBMS_PIPE
IF result <>
RAISE_APPLICATION_ERROR(
END IF
DBMS_PIPE
DBMS_OUTPUT
command_code)
RETURN command_code
END execute_system
/*stop是讓daemon停止*/
PROCEDURE stop(timeout NUMBER DEFAULT
status NUMBER
BEGIN
DBMS_PIPE
status := DBMS_PIPE
IF status <>
RAISE_APPLICATION_ERROR(
END IF
END stop
END daemon
通過Sql*Plus運行以上語句
#include
#include
EXEC SQL INCLUDE SQLCA
EXEC SQL BEGIN DECLARE SECTION
char *uid =
int status
VARCHAR command[
VARCHAR value[
VARCHAR return_name[
EXEC SQL END DECLARE SECTION
void
connect_error()
{
char msg_buffer[
int msg_length
int buffer_size =
From:http://tw.wingwit.com/Article/program/Oracle/201311/17032.html