Re: Pipe from pl/sql block to a c-deamon

From: Ronald <_ronr__at__worldaccess_._nl_>
Date: 1997/07/22
Message-ID: <AFFAC6EB966854E13_at_0.0.0.0>#1/1


In article <33D39AB4.5CE27352_at_myself.com>, Marc Mathieu <marc_at_myself.com> wrote:

>Subject: Re: Pipe from pl/sql block to a c-deamon
>From: Marc Mathieu
>Reply-To: marc_at_myself.com
>Organization: VTL
>Date: Mon, 21 Jul 1997 13:21:56 -0400
>Newsgroups: comp.databases.oracle.tools
>
>Vidar Mikkelsen wrote:
>
>> Can somebody please show me the syntax to send a message
>> from a pl/sql block to a c-deamon thru a pipe ??
>>
>> Thank's
>
> I have a similar issue, I would like to create the daemon in
>Developper/2000...
>

Just make a little package with a send and receive procedure for DBMS_PIPE. This is a little example from the Application Developers Guide page 284.

basically it's just packing data, sending to some pipe and receiving it on the other end. Personally I would create a server and a client stub in a package, much like flex does. (http://govt.us.oracle.com/)

Example
A Ð 22 Application DeveloperÕs Guide
The following example shows a procedure that could be called by a PL/SQL program to place debugging information in a pipe: CREATE OR REPLACE PROCEDURE debug(info VARCHAR2) IS s NUMBER;
BEGIN
DBMS_PIPE.PACK_MESSAGE(info);
s := DBMS_PIPE.SEND_MESSAGE(Õplsql_debugÕ); IF s <> 0 THEN
RAISE_APPLICATION_ERROR(Ð2000, ÕDebug errorÕ); ENDIF;
END;
/
The following code is a Pro*C example of a pipe used to retrieve the messages sent using the DEBUG procedure and display them in a window. Any errors raised by the PL/SQL code by calling DEBUG are noticed by the Pro*C pipe application and displayed in a second window.
#include <stdio.h>
#include <string.h>
exec sql begin declare section;
VARCHAR username[64];
int status;
char retval[128];
exec sql end declare section;
exec sql include sqlca;
void sql_error(void);
A Ð 23 Supplied Packages
main(argc, argv)
int argc;
char **argv;
{
/* prepare username */
if (argc 1)
strncpy(username.arr, argv[1], sizeof (username.arr) Ð 1); else
strcpy(username.arr, ÓSCOTT/TIGERÓ);
username.len = strlen(username.arr);
exec sql whenever sqlerror do sql_error(); exec sql connect :username;
printf(Óconnected\nÓ);
/* start an endless loop to look for and print messages on the pipe */
for (;;)
{
exec sql execute
declare
s integer;
chr varchar2(200);
begin
chr := ÕÕ;
s := dbms_pipe.receive_message(Õplsql_debugÕ); if s = 0 then
dbms_pipe.unpack_message(chr);
end if;
:status := s;
:retval := chr;
end;
endÐexec;
if (status == 0)
printf(Ó\n%s\nÓ, retval);
else
printf(Óabnormal status, value is %d\nÓ, status); }
}
void sql_error(void)
{
char msg[1024];
int rlen, len;
len = sizeof(msg);

sqlglm(msg, &len, &rlen);
printf(ÓORACLE ERROR\nÓ);
printf(Ó%.*s\nÓ, rlen, msg);

exit(1);
}

cheers !

Ronald



mailto:_ronr__at__worldaccess.nl_
http://www.worldaccess.nl/~ronr (last update: may 24, 1997) (to reply, remove "_" from email address) Received on Tue Jul 22 1997 - 00:00:00 CEST

Original text of this message