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