09.12.2012 Views

Advanced Queuing - Oracle

Advanced Queuing - Oracle

Advanced Queuing - Oracle

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

char subject[30]; /* components of */<br />

char txt[80]; /* Message_typ */<br />

char correlation1[30]; /* message correlation */<br />

char correlation2[30];<br />

int status; /* code returned by the OCI calls */<br />

/* Dequeue by correlation and msgid */<br />

/* Connect to the database: */<br />

EXEC SQL CONNECT :user;<br />

EXEC SQL WHENEVER SQLERROR DO sql_error("<strong>Oracle</strong> Error :");<br />

/* Allocate space in the object cache for the host variable: */<br />

EXEC SQL ALLOCATE :message;<br />

/* Get the OCI Env handle: */<br />

if (SQLEnvGet(SQL_SINGLE_RCTX, &oeh) != OCI_SUCCESS)<br />

{<br />

printf(" error in SQLEnvGet \n");<br />

exit(1);<br />

}<br />

/* Get the OCI Error handle: */<br />

if (status = OCIHandleAlloc((dvoid *)oeh, (dvoid **)&err,<br />

(ub4)OCI_HTYPE_ERROR, (ub4)0, (dvoid **)0))<br />

{<br />

printf(" error in OCIHandleAlloc %d \n", status);<br />

exit(1);<br />

}<br />

/* Assign memory for msgid:<br />

Memory needs to be allocated explicitly to OCIRaw*: */<br />

if (status=OCIRawAssignBytes(oeh, err, msgmem, 16, &msgid))<br />

{<br />

printf(" error in OCIRawAssignBytes %d \n", status);<br />

exit(1);<br />

}<br />

/* First enqueue */<br />

Enqueuing and Dequeuing Of Messages<br />

strcpy(correlation1, "1st message");<br />

strcpy(subject, "NORMAL ENQUEUE1");<br />

strcpy(txt, "The Enqueue was done through PLSQL embedded in PROC");<br />

/* Initialize the components of message: */<br />

<strong>Oracle</strong> <strong>Advanced</strong> <strong>Queuing</strong> by Example A-39

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!