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.

EXEC SQL CONNECT :user;<br />

/* On an oracle error print the error number :*/<br />

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

Enqueuing and Dequeuing Of Messages<br />

/* Allocate memory for the host variable from the object cache : */<br />

EXEC SQL ALLOCATE :message;<br />

/* ENQUEUE */<br />

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

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

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

EXEC SQL OBJECT SET subject, text OF :message TO :subject, :txt;<br />

/* Embedded PLSQL call to the AQ enqueue procedure : */<br />

EXEC SQL EXECUTE<br />

DECLARE<br />

message_properties dbms_aq.message_properties_t;<br />

enqueue_options dbms_aq.enqueue_options_t;<br />

msgid RAW(16);<br />

BEGIN<br />

/* Bind the host variable ’message’ to the payload: */<br />

dbms_aq.enqueue(queue_name => ’msg_queue’,<br />

message_properties => message_properties,<br />

enqueue_options => enqueue_options,<br />

payload => :message:imsg, /* indicator has to be specified */<br />

msgid => msgid);<br />

END;<br />

END-EXEC;<br />

/* Commit work */<br />

EXEC SQL COMMIT;<br />

printf("Enqueued Message \n");<br />

printf("Subject :%s\n",subject);<br />

printf("Text :%s\n",txt);<br />

/* Dequeue */<br />

/* Embedded PLSQL call to the AQ dequeue procedure : */<br />

EXEC SQL EXECUTE<br />

DECLARE<br />

message_properties dbms_aq.message_properties_t;<br />

dequeue_options dbms_aq.dequeue_options_t;<br />

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

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

Saved successfully!

Ooh no, something went wrong!