09.12.2012 Views

Advanced Queuing - Oracle

Advanced Queuing - Oracle

Advanced Queuing - Oracle

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

AQ and Memory Usage<br />

OCIHandleAlloc((dvoid *)envhp, (dvoid **)&usrhp, (ub4) OCI_HTYPE_SESSION,<br />

(size_t) 0, (dvoid **) 0);<br />

OCIAttrSet((dvoid *)usrhp, (ub4)OCI_HTYPE_SESSION,<br />

(dvoid *)"scott", (ub4)strlen("scott"), OCI_ATTR_USERNAME, errhp);<br />

OCIAttrSet((dvoid *)usrhp, (ub4)OCI_HTYPE_SESSION,<br />

(dvoid *)"tiger", (ub4)strlen("tiger"), OCI_ATTR_PASSWORD, errhp);<br />

checkerr(errhp, OCISessionBegin (svchp, errhp, usrhp, OCI_CRED_RDBMS,<br />

OCI_DEFAULT));<br />

OCIAttrSet((dvoid *)svchp, (ub4)OCI_HTYPE_SVCCTX,<br />

(dvoid *)usrhp, (ub4)0, OCI_ATTR_SESSION, errhp);<br />

/* Allocate a message properties descriptor to fill in correlation id :*/<br />

checkerr(errhp, OCIDescriptorAlloc(envhp, (dvoid **)&msgprop,<br />

OCI_DTYPE_AQMSG_PROPERTIES,<br />

0, (dvoid **)0));<br />

do {<br />

printf("Enter a line of text (max 80 chars):");<br />

if (!gets((char *)buf))<br />

break;<br />

enqmesg((ub4)msgno++, buf);<br />

} while(1);<br />

/* Free the message properties descriptor: */<br />

checkerr(errhp, OCIDescriptorFree((dvoid *)msgprop,<br />

OCI_DTYPE_AQMSG_PROPERTIES));<br />

} /* end main */<br />

static void checkerr(errhp, status)<br />

LNOCIError *errhp;<br />

sword status;<br />

{<br />

text errbuf[512];<br />

ub4 buflen;<br />

sb4 errcode;<br />

if (status == OCI_SUCCESS) return;<br />

switch (status)<br />

{<br />

case OCI_ERROR:<br />

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

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

Saved successfully!

Ooh no, something went wrong!