Improve PHP performance by caching database results (2)

Source: Internet
Author: User
Create a notification handler
Now you can create a notification handler, which will use the sendNotification
The process sends a change notification to the client. Let's take a look at the PL/SQL process orders_nf_callback in listing 2.
List 2.
Notification handler that processes changes to the OE. ORDERS table

Create or replace procedure orders_nf_callback (ntfnds in sys. CHNF $ _ DESC) IS
Tblname VARCHAR2 (60 );
Numtables NUMBER;
Event_type NUMBER;
Row_id VARCHAR2 (20 );
Numrows NUMBER;
Ord_id VARCHAR2 (12 );
Url VARCHAR2 (256): = 'http: // webserverhost/phpcache/dropResults. php? Order_no = ';
BEGIN
Event_type: = ntfnds. event_type;
Numtables: = ntfnds. numtables;
IF (event_type = DBMS_CHANGE_NOTIFICATION.EVENT_OBJCHANGE) THEN
FOR I IN 1 .. numtables LOOP
Tblname: = ntfnds. table_desc_array (I). table_name;
IF (bitand (ntfnds. table_desc_array (I). opflags,
Dbms_change_icationication.all_rows) = 0) THEN
Numrows: = ntfnds. table_desc_array (I). numrows;
ELSE
Numrows: = 0;
End if;
IF (tblname = 'Oe. ORDERS ') THEN
FOR j IN 1 .. numrows LOOP
Row_id: = ntfnds. table_desc_array (I). row_desc_array (j). row_id;
SELECT order_id INTO ord_id FROM orders WHERE rowid = row_id;
SendNotification (url, tblname, ord_id );
End loop;
End if;
End loop;
End if;
COMMIT;
END;
/
As shown in "list 2", this notification handler will SYS. CHNF $ _ DESC
ObjectUse it as a parameter, and then use its properties to obtain detailed information about the change. In this example, the notification handler only processes DatabaseDML or DDL for responding to registered objects
Change (that is, only when the notification type is EVENT_OBJCHANGE
And ignore notifications about other database events (such as instance startup or instance shutdown. From a later version, the handler can process
A change notification is sent to each affected row in the table. In the "Add table to existing registration" section after this article, you will add several lines of code to the handler so that it can process
The row to be modified in the table.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.