Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: DBMS_ALERT

Re: DBMS_ALERT

From: John Emmerling <jemmerli_at_cscmail.csc.com>
Date: 1997/12/30
Message-ID: <01bd1543$965ad810$7d1456c0@c-104638>#1/1

Roelof den Dekker <roelof.den.dekker_at_cmg.nl> wrote in article <01bd144b$c05d88e0$02c2100a_at_roelofdd.att.cmg.nl>...
> Does anyone have experience with the DBMS_ALERT functions ?
>
> Please send some example code I don't know what parameters exactly to use
> in the .register and .waitone functions.
>
> Roelof
>

Here's some example Pro*C code that should cover what you need to know:

=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+

#include <stdio.h>
#include <string.h>
#include "DbAccessProcs.int"
#include "LogMessage.int"
#include "exception.h"

#include "Alert.int"

#define HANDLE_EXCEPTION__SQLERROR() \

                                        HANDLE_EXCEPTION( ERR__SQLERROR)
EXEC SQL INCLUDE CommonDBA.h;

/***************************************************************
 *
 *   RegisterEventChange

 *
 ***************************************************************/
Status_T
RegisterEventChange()
{

    static char * UNITNAME = "RegisterEventChange";

    EXEC SQL WHENEVER SQLERROR DO HANDLE_EXCEPTION__SQLERROR();     EXEC SQL EXECUTE

       BEGIN
	  dbms_alert.register( 'EventChangeAlert');
       END;

    END-EXEC;     return SUCCESS;

    exception ERR__SQLERROR:

    {        
       int sqlcode = sqlca.sqlcode;
       DbLogError( CODE_LOCATION );

       LogMessage( CODE_LOCATION, MSG_SQLERROR, sqlcode, NULL);
       return ERROR;

    }  

}  

/***************************************************************
 *
 *   WaitEventChange

 *
 ***************************************************************/
Status_T
WaitEventChange(
	Boolean *timedOut, /*o: TRUE if time out occured*/
	char*   message
	)

{

    static char * UNITNAME = "WaitEventChange";     EXEC SQL BEGIN DECLARE SECTION;

       int status;
	VARCHAR v_message[101];
	short v_msgnull;

    EXEC SQL END DECLARE SECTION;     EXEC SQL WHENEVER SQLERROR DO HANDLE_EXCEPTION__SQLERROR();     v_message.len = 100;
    v_message.arr [100] = '\0';

    EXEC SQL EXECUTE

       DECLARE
	  messages VARCHAR2(100);
       BEGIN
--          dbms_alert.waitone( 'EventChangeAlert', messages, 
--                                      :status, 20);
	  dbms_alert.waitone( 'EventChangeAlert', :v_message:v_msgnull, 
					:status, 20);
       END;

    END-EXEC;     if (v_msgnull)
    {

        message [0] = '\0';
    }
    else
    {

	strncpy (message, v_message.arr, v_message.len);
	message [v_message.len] = '\0';

    }
    /* if status is 1 then time out occured */     *timedOut = (status) ? TRUE:FALSE;

    return SUCCESS;

    exception ERR__SQLERROR:
    {

	int sqlcode = sqlca.sqlcode;
	DbLogError( CODE_LOCATION );
       
	LogMessage( CODE_LOCATION, MSG_SQLERROR, sqlcode, NULL);
	return ERROR;

    }

}  

/***************************************************************
 *
 *   RemoveEventChange

 *
 ***************************************************************/
Status_T
RemoveEventChange()
{

    static char * UNITNAME = "RemoveEventChange";

    EXEC SQL EXECUTE

       BEGIN
	  dbms_alert.remove( 'EventChangeAlert');
       END;

    END-EXEC;     return SUCCESS;
    exception ERR__SQLERROR:
    {
	int sqlcode = sqlca.sqlcode;
	DbLogError( CODE_LOCATION );

	LogMessage( CODE_LOCATION, MSG_SQLERROR, sqlcode, NULL);
	return ERROR;

    }
} Received on Tue Dec 30 1997 - 00:00:00 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US