SQL/MX Queuing and Publish/Subscribe Services
Embedded SQL Examples
HP NonStop SQL/MX Queuing and Publish/Subscribe Services—523734-002
3-5
Skip Conflict Access
EndOfProcessing:
EXEC SQL WHENEVER SQLERROR GOTO EndError;
EXEC SQL CLOSE arrivals;
EndError:
return SQLCODE;
}
------------------------------------------------------------
Skip Conflict Access
Skip conflict access prevents concurrent transactions from blocking each other while
waiting for the release of locks on rows currently being inserted or updated when other
rows are available that are not locked. This program illustrates the skip conflict access
mode:
---------------------------------------------------------------
#include <stdio.h>
#include <string.h>
long SkipConflict()
{
EXEC SQL BEGIN DECLARE SECTION;
int destination;
int origin;
int seqnbr;
long SQLCODE;
EXEC SQL END DECLARE SECTION;
EXEC SQL WHENEVER SQLERROR GOTO EndOfProcessing;
EXEC SQL DECLARE arrivals CURSOR WITH HOLD FOR
SELECT destination, origin, seqnbr
FROM
(DELETE FROM STREAM(inbox)
FOR SKIP CONFLICT ACCESS) AS inbox;
EXEC SQL BEGIN WORK; /* Start transaction */
EXEC SQL OPEN arrivals;
/* Wait for newly arrived parcels and notify receivers */
while (1) {
/* Dequeue notifications */
EXEC SQL FETCH arrivals
INTO :destination,:origin,:seqnbr;
printf("\nDestination:%d Origin:%d "
"Sequence number:%d",
destination, origin, seqnbr);
/* Route package and notify receivers*/
routePackage(seqnbr, destination, origin);
EXEC SQL COMMIT WORK; /* Commit transaction */
EXEC SQL BEGIN WORK; /* Start new transaction */
}