Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: DBMS_ALERT
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
static char * UNITNAME = "RegisterEventChange";
EXEC SQL WHENEVER SQLERROR DO HANDLE_EXCEPTION__SQLERROR(); EXEC SQL EXECUTE
BEGIN dbms_alert.register( 'EventChangeAlert'); END;
exception ERR__SQLERROR:
{ int sqlcode = sqlca.sqlcode; DbLogError( CODE_LOCATION ); LogMessage( CODE_LOCATION, MSG_SQLERROR, sqlcode, NULL); return ERROR;
}
/*************************************************************** * * WaitEventChange
***************************************************************/Status_T
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 EXECUTE
DECLARE messages VARCHAR2(100); BEGIN -- dbms_alert.waitone( 'EventChangeAlert', messages, -- :status, 20); dbms_alert.waitone( 'EventChangeAlert', :v_message:v_msgnull, :status, 20); END;
message [0] = '\0';
}
else
{
strncpy (message, v_message.arr, v_message.len); message [v_message.len] = '\0';
return SUCCESS;
exception ERR__SQLERROR:
{
int sqlcode = sqlca.sqlcode; DbLogError( CODE_LOCATION ); LogMessage( CODE_LOCATION, MSG_SQLERROR, sqlcode, NULL); return ERROR;
}
/*************************************************************** * * RemoveEventChange
***************************************************************/Status_T
static char * UNITNAME = "RemoveEventChange";
EXEC SQL EXECUTE
BEGIN dbms_alert.remove( 'EventChangeAlert'); END;
int sqlcode = sqlca.sqlcode; DbLogError( CODE_LOCATION ); LogMessage( CODE_LOCATION, MSG_SQLERROR, sqlcode, NULL); return ERROR;
![]() |
![]() |