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.

AQ and Memory Usage<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 />

OCIErrorGet ((dvoid *) errhp, (ub4) 1, (text *) NULL, &errcode,<br />

errbuf, (ub4) sizeof(errbuf), (ub4) OCI_HTYPE_ERROR);<br />

printf("Error - %s\n", errbuf);<br />

break;<br />

case OCI_INVALID_HANDLE:<br />

printf("Error - OCI_INVALID_HANDLE\n");<br />

break;<br />

default:<br />

printf("Error - %d\n", status);<br />

break;<br />

}<br />

exit(-1);<br />

} /* end checkerr */<br />

Enqueuing Messages (Reuse Memory) Using OCI<br />

This program, enqreuse.c, enqueues each line of text into a queue 'msgqueue'<br />

that has been created in scott's schema by executing create_types.sql. Each line<br />

of text entered by the user is stored in the queue until user enters EOF. In this<br />

program the enqueue subroutine reuses the memory for the message payload, as<br />

well as the AQ message properties descriptor.<br />

#ifndef OCI_ORACLE<br />

#include <br />

#endif<br />

#include <br />

static void checkerr(OCIError *errhp, sword status);<br />

static void enqmesg(ub4 msgno, text *buf);<br />

A-76 <strong>Oracle</strong>9i Application Developer’s Guide - <strong>Advanced</strong> <strong>Queuing</strong>

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

Saved successfully!

Ooh no, something went wrong!