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.

tkaqdocd.sql: Examples of Administrative and Operational Interfaces<br />

/* query old status from the table */<br />

SELECT st.status INTO old_status from order_status_table st<br />

where st.customer_order.orderno = order_msg.orderno;<br />

/* Status can be 'BOOKED_ORDER', 'SHIPPED_ORDER', 'BACK_ORDER'<br />

* and 'BILLED_ORDER'<br />

*/<br />

IF new_status = 'SHIPPED_ORDER' THEN<br />

IF old_status = 'BILLED_ORDER' THEN<br />

return; /* message about a previous state */<br />

END IF;<br />

ELSIF new_status = 'BACK_ORDER' THEN<br />

IF old_status = 'SHIPPED_ORDER' OR old_status = 'BILLED_ORDER' THEN<br />

return; /* message about a previous state */<br />

END IF;<br />

END IF;<br />

/* update the order status */<br />

UPDATE order_status_table st<br />

SET st.customer_order = order_msg, st.status = new_status<br />

where st.customer_order.orderno = order_msg.orderno;<br />

COMMIT;<br />

EXCEPTION<br />

WHEN OTHERS THEN /* change to no data found */<br />

/* first update for the order */<br />

INSERT INTO order_status_table(customer_order, status)<br />

VALUES (order_msg, new_status);<br />

COMMIT;<br />

END;<br />

END;<br />

/<br />

Rem<br />

Rem Monitors the customer service queues for 'time' seconds<br />

Rem<br />

CREATE OR REPLACE PROCEDURE MONITOR_STATUS_QUEUE(time IN NUMBER)<br />

IS<br />

agent_w_message aq$_agent;<br />

agent_list dbms_aq.agent_list_t;<br />

C-18 <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!