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

Source: Internet
Author: User
Tags strcmp
The Oracle tutorial you are looking at is: How Oracle runs the OS command directly (bottom). EXEC SQL whenever SQLERROR CONTINUE;
SQLGLM (Msg_buffer, &buffer_size, &msg_length);
printf ("Daemon error while connecting:\n");
printf ("%.*s\n", Msg_length, Msg_buffer);
printf ("Daemon quitting.\n");
Exit (1);
}

void
Sql_error ()
{
Char msg_buffer[512];
int msg_length;
int buffer_size = 512;

EXEC SQL whenever SQLERROR CONTINUE
Sqlglm (Msg_buffer, &buffer_size, &msg_length);
printf (Daemo  N Error while executing:\n ");
printf ("%.*s\n ", Msg_length, Msg_buffer);
printf (" Daemon continuing.\n ");

Main ()  

Exec sql whenever SQLERROR do Connect_error ();
Exec SQL Connect:uid;
printf ("Daemon connected.\n");

Exec SQL whenever SQLERROR do Sql_error ();
printf ("Daemon waiting...\n"),
while (1) { 
EXEC SQ L execute 
begin 
/* Receives the character from the Deamon */ 
: Status: = Dbms_pipe. Receive_message (' daemon ');
If:status = 0 then 
/* Fetch character */ 
Dbms_pipe. Unpack_message (: command);
end IF;
End;
End-exec
if (status = 0)  

Comman D.arr[command.len] = ' yes ';
/* If it is a STOP, the process exits */ 
if (!strcmp (char *) Command.arr, "STOP")  
{&N Bsp
printf ("Daemon exiting.\n");
break;

ELSE IF (!strcmp (char *) Command.arr, "SYSTEM")
{
EXEC SQL EXECUTE
BEGIN
Dbms_pipe. Unpack_message (: Return_name);
Dbms_pipe. Unpack_message (: value);
End;
End-exec;
Value.arr[value.len] = ' the ';
printf ("Would execute system command '%s ' \ n", Value.arr);
/* Run OS command/*
Status = System (Value.arr);
EXEC SQL EXECUTE
BEGIN
Dbms_pipe. Pack_message (' done ');
Dbms_pipe. Pack_message (: status);
: Status: = Dbms_pipe. Send_message (: Return_name);
End;
End-exec;

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.