Chapter 11. Administering SQL Remote for AdaptiveSer verAnywhere
// Log the error
INSERT INTO cons.replication_audit
( remoteuser, errormsg)
VALUES
( current_remote_user, error_text);
COMMIT WORK;
//Now notify the DBA an error has occurred
// using email. We only want this information if
// the error occurred on the consolidated database
// We want the email to contain the error strings
// the Message Agent is passing to the procedure
IF CURRENT PUBLISHER = ’cons’ THEN
CALL sp_notify_DBA( error_text );
END IF
END;
Thestored procedure calls another stored procedure to manage the sendingofEmail:
CREATE PROCEDURE sp_notify_DBA( in msg long varchar)
BEGIN
DECLARE rc INTEGER;
rc=call xp_startmail( mail_user=’davidf’ );
//If successful logon to mail
IF rc=0 THEN
rc=call xp_sendmail(
recipient=’Doe, John; John, Elton’,
subject=’SQL Remote Error’,
"message"=msg);
//If mail sent successfully, stop
IF rc=0 THEN
call xp_stopmail()
END IF
END IF
END;

Anaudit table Anaudit table could be defined as follows:

CREATE TABLE replication_audit (
id INTEGER DEFAULT AUTOINCREMENT,
pub CHAR(30) DEFAULT CURRENT PUBLISHER,
remoteuser CHAR(30),
errormsg LONG VARCHAR,
timestamp DATETIME DEFAULT CURRENT TIMESTAMP,
PRIMARY KEY (id,pub)
);
Thecolumns have the following meaning:247