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 3597378
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:06:39+00:00 2026-05-18T20:06:39+00:00

Good Afternoon. I have been working with Oracle Advanced Queues to create a messaging

  • 0

Good Afternoon.

I have been working with Oracle Advanced Queues to create a messaging system that we can use to determine when new lines are passed into the databse, when updates occur and when deletes occur.

I am using a single consumer queue and using correlations to control what data is looked for at certain times and my payload is of xmltype.

To generate the xml, I originally was using an xmlsequence to generate the message as below.

<MESSAGE>
<LOCATIONS>
  <LOCATION_ID>9999</LOCATION_ID>
  <LOC_TYPE>S</LOC_TYPE>
  <NAME>Test Location</NAME>
  <RETAILER_UNIT_CODE>T&amp;L</RETAILER_UNIT_CODE>
  <REGION_CODE>SA</REGION_CODE>
  <DELETE_FLAG>N</DELETE_FLAG>
  <EXTERNAL_WHSE_FLAG>N</EXTERNAL_WHSE_FLAG>
  <CREATED_BY>SYSADMIN</CREATED_BY>
  <CREATED_DATE>04/MAR/08</CREATED_DATE>
  <STATE_CODE>SA</STATE_CODE>
  <ADDRESS>223 Road Ridsonville</ADDRESS>
  <POSTCODE>1234</POSTCODE>
  <PHONE_NUM>08 </PHONE_NUM>
  <LAST_MODIFIED_BY>SYSADMIN</LAST_MODIFIED_BY>
  <LAST_MODIFIED_DATE>21/APR/09</LAST_MODIFIED_DATE>
  <POS_CODE>TRANS</POS_CODE>
  <SOP_FLAG>N</SOP_FLAG>
</LOCATIONS>
</MESSAGE>

However, it has come to my attention that xmlsequence leaves out null elements, which is not ideal, as when it comes time for the messages to be picked up at the other end, they cannot be mapped on data field easily.
To try and work around this, I have tried to employ the use of DBMS_XMLGEN within my trigger, as it allows the handling of nulls in exactly the way I would want it handled.

ctx := dbms_xmlgen.newContext('SELECT * FROM LOCATIONS WHERE LOCATION_ID = ' || :new.LOCATION_ID);
dbms_xmlgen.setrowsettag(ctx, 'MESSAGE');
dbms_xmlgen.setrowtag(ctx, 'LOCATIONS');
dbms_xmlgen.setnullhandling(ctx, dbms_xmlgen.EMPTY_TAG);
l_xml:=dbms_xmlgen.getxmltype(ctx);

The problem with this approach is that it will generate an exception, as it is trying to operate on the same table that the trigger has been executed from.

ORA-04091: table RIT.LOCATIONS is mutating, trigger/function may not see it

So I moved on to trying to use the new and old objects to get the data out and place it in to the context, but I am running in to a few hiccups with the values that are null, as they are playing havoc with my concatenating them in to the query string.

...
REFERENCING NEW AS NEW OLD AS OLD
for each row 
DECLARE
l_xml   xmltype;
ctx       dbms_xmlgen.ctxHandle;
begin
ctx := dbms_xmlgen.newContext('SELECT   '||:new.id||'as id, '||:new.nullfield||' as nullfield from dual');
dbms_xmlgen.setrowsettag(ctx, 'MESSAGE');
dbms_xmlgen.setrowtag(ctx, 'INT_CREDIT_CLAIMS');
dbms_xmlgen.setnullhandling(ctx, dbms_xmlgen.EMPTY_TAG);
l_xml:=dbms_xmlgen.getxmltype(ctx);
...
end;

So my question is: How can I go about solving this so that I can see my empty elements for my xml type?

I’m also open to suggestions along the way on how to solve it and will be checking back for any clarification requests.

  • 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-18T20:06:40+00:00Added an answer on May 18, 2026 at 8:06 pm

    to generate a simple row in XML you can use xmlelement:

    SQL> CREATE TABLE emp AS SELECT * FROM scott.emp;
    
    Table created
    
    SQL> CREATE TABLE message (xml XMLTYPE);
    
    Table created
    
    SQL> CREATE OR REPLACE TRIGGER trg_b4_emp
      2     BEFORE UPDATE ON emp
      3     FOR EACH ROW
      4  BEGIN
      5     INSERT INTO message VALUES (
      6       xmlelement("MESSAGE",
      7           xmlelement("EMP",
      8              xmlelement("empno", :new.empno),
      9              xmlelement("comm", :new.comm)
     10           )
     11        )
     12     );
     13  END;
     14  /
    
    SQL> update emp set comm=NULL;
    
    14 rows updated
    
    SQL> select * from message where rownum = 1;
    
    XML
    ----------------------------------------------------------------
    <MESSAGE><EMP><empno>7369</empno><comm></comm></EMP></MESSAGE>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good Afternoon. I have been working with Oracle Advanced Queues to create a messaging
Good afternoon, I have been working on a dll that can use CORBA to
Good afternoon people's I have built a jquery plugin that I use on my
Very good afternoon to all, The problem I have now is that I can
Good afternoon. I have been making a small openGL based app for android that
Good afternoon all, I have a Java applet that I wish to embed on
Good afternoon I have a table that has customer id, name, computer, laptop, blah,
Good afternoon. I have a Repeater with a ItemTemplate that prints one column with
Good Afternoon All, I have a wizard control that contains 20 textboxes for part
Good Afternoon, I have a Joomla! template that keeps throwing up a pop up

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.