Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6388337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:15:58+00:00 2026-05-25T03:15:58+00:00

I read some example of how to use DBMS_CHANGE_NOTIFICATION for an asynchronous trigger. I

  • 0

I read some example of how to use DBMS_CHANGE_NOTIFICATION for an asynchronous trigger.

I need to create a trigger for table CONTENT only if STATUS = 1709003.

So I created the following PROCEDURE:

  CREATE OR REPLACE PROCEDURE tables_changed_chnt(ntfnds IN SYS.chnf$_desc) IS
  l_table_name              VARCHAR2(60);
  l_event_type              NUMBER;
  l_numtables               NUMBER;
  status                    NUNBER;
  Row_id                    VARCHAR2(20);
  numrows                   NUMBER;
  token                     varchar2(100);
  subject                   varchar2(100);
  message                   varchar2(100);
  result                    varchar2(100);
  planid                                number := 0;
  userId                                    number := -10000;
  stoponefromatmissing          number := 0;
  timetostopprocess                 number := 0;
  retrials                                number := 2;
  stoponeinvalidaddress         number := 0;
  NL_CONTENT                number:=-1;
  event_status              number:=-1;
BEGIN
  l_numtables  := ntfnds.numtables;
  l_event_type := ntfnds.event_type;

  IF l_event_type = DBMS_CHANGE_NOTIFICATION.EVENT_OBJCHANGE THEN
    FOR i IN 1 .. l_numtables LOOP
      l_table_name      := ntfnds.table_desc_array(i).table_name;

      if l_table_name = 'CONTENT' then
        IF (bitand(operation_type, DBMS_CHANGE_NOTIFICATION.ALL_ROWS) = 0) THEN
          numrows := ntfnds.table_desc_array(i).numrows;
        ELSE 
          numrows :=0;   /* ROWID INFO NOT AVAILABLE */
        END IF;
       FOR j IN 1..numrows LOOP
         Row_id := ntfnds.table_desc_array(i).row_desc_array(j).row_id;
         select NL_CONTENT_ID into NL_CONTENT from CONTENT where rownum=:Row_id;
         select event_status_code into status from CONTENT where rownum=:Row_id; 
          if (status = 1709003) then
            select NL_CONTENT_PLAN_ID into planid from NL_CONTENT where NL_CONTENT_ID=:NL_CONTENT;
            result := workflow_cust.om_start_delivery(token,
                                             subject,
                                             message,
                                             planid,
                                                                     userId,
                                             stoponefromatmissing,
                                             timetostopprocess,
                                             retrials,
                                             stoponeinvalidaddress);
         end if;
      END LOOP;   
      end if    
    END LOOP; 
  END IF;      
END;

I saw that I need to invoke it with something similar to:

DECLARE
  REGDS      SYS.CHNF$_REG_INFO;
  regid      NUMBER;
  cust_id    varchar2(20);
  qosflags   NUMBER;
BEGIN
qosflags := DBMS_CHANGE_NOTIFICATION.QOS_RELIABLE + DBMS_CHANGE_NOTIFICATION.
 QOS_ROWIDS;
REGDS := SYS.CHNF$_REG_INFO ('SP_EVENT_GENERATE', qosflags, 0,0,0);
regid := DBMS_CHANGE_NOTIFICATION.NEW_REG_START (REGDS); 
  /* registe the customer table */
SELECT CUSTID INTO cust_id  FROM TB_CUSTOMER WHERE ROWNUM=1;
DBMS_CHANGE_NOTIFICATION.REG_END;
END;
  1. What do I need to write instead of SELECT CUSTID INTO cust_id FROM TB_CUSTOMER WHERE ROWNUM=1;

  2. Is there a way to retrieve the changed object, instead only the rowid – since it will save me time to do the find in the first procedure?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T03:15:58+00:00Added an answer on May 25, 2026 at 3:15 am

    In the registration block (between DBMS_CHANGE_NOTIFICATION.NEW_REG_START and DBMS_CHANGE_NOTIFICATION.REG_END), you need to execute a simple query on the table CONTENT to register your interest in changes to this table, e.g.:

    SELECT select NL_CONTENT_ID into NL_CONTENT from CONTENT WHERE ROWNUM = 1;
    

    Access by ROWID is very fast. So I don’t see any potential for saving time except that you can combine the two queries into one:

    select NL_CONTENT_ID, EVENT_STATUS_CODE into NL_CONTENT, STATUS from CONTENT
    where ROWID = Row_id;
    

    Note that I have changed the WHERE clause: it’s ROWID not ROWNUM.

    BTW: The line:

    REGDS := SYS.CHNF$_REG_INFO ('SP_EVENT_GENERATE', qosflags, 0,0,0);
    

    shoud probably be:

    REGDS := SYS.CHNF$_REG_INFO ('TABLES_CHANGED_CHNT', qosflags, 0,0,0);
    

    or your stored procedure should be renamed to SP_EVENT_GENERATE.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using hibernate. i have read some where about Example.create. what is it
i never use sql server ROW_NUMBER() function. so i read some article regarding ROW_NUMBER(),PARTITION
I can't found some example how can I use argument -a when I use
I'd like to read some data which itself specifies the data type to use.
I have noticed some programs explicitly zero sensitive memory allocations after use. For example,
I found some example of how to read the XML from an Excel spreadsheet
I read some of the answers on here re: testing views and controllers, and
I read some properties from an xml file, amongst which is a string that
I read some source code of ZenTest but didn't find where it is implemented.
I read some articles about Comet tech. All of them mentioned that the long-life

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.