How to omit elements/attributes if the value of the element is zero?

Hi gurus

It's me again. with a quick question...
I'm sure everyone knows the difference between these two statements (running in the SCOTT schema):

Select
XmlElement ('employees',
XMLAGG)
XMLFOREST (comm as "SalesCommEmployee")
)
)
EMP;

Select
XmlElement ('employees',
XMLAGG)
XmlElement ("SalesCommEmployee", comm)
)
)
EMP;

First statement out fewer records because XMLFOREST shows nothing if the value of the element is null.
But what happens if element has attributes?. Say:

Select
XmlElement ('employees',
XMLAGG)
XmlElement ("SalesCommEmployee", xmlattributes (empno as "id"), comm)
)
)
EMP;

Is it possible to omit any element (including attributes) if the value of the element is set to zero.
Of course, it is a simplistic example, in this case, a WHERE clause would solve the problem.
In my particular case, I am managing a huge SELECT with multiple levels of xml and some elements (with attributes), may have null values, and must be included in this case nothing.

I am considering a dirty search/delete option on the output, but I think that a more elegant solution must exist.

Can you give me some advice?

Thank you
Oscar

Hello

You can use a CASE statement, DECODE or NVL2 functions.

Here is an example with NVL2 (returns 2nd argument if the 1st is not not null, otherwise the 3rd):

SQL> select xmlserialize(document
  2           xmlelement("Employees",
  3             xmlagg(
  4               nvl2( comm
  5                   , xmlelement("SalesCommEmployee", xmlattributes(empno as "id"), comm)
  6                   , null )
  7             )
  8           )
  9           as clob indent
 10         ) as result
 11  from scott.emp
 12  ;

RESULT
--------------------------------------------------------------------------------

  300
  500
  1400
  0

 

Tags: Database

Similar Questions

  • How Gerez af:query attributed to the location of perforem in the

    I ' am on Jdeveloper Studio Edition Version 11.1.2.3.0

    I have a request of adf

    I make location on my request for 2 languages successfully

    I only have 2 properties files in the ViewController and I ' save my people and the 2 files bundle_de.properties and bundle_en.properties in the facesf-config. XML

    and I'm under Select an element of choice on the page home.jspx to allow the end-user to switch between languages as he likes

    in fact all works well

    all menus, forms, and tables he gets a correct language

    but only the internal attributes of the af: query

    they always reads the model resource group

    so please if anyone can guide me how I can join af:query attributes to set the variable bundle of resource for them to reade of

    or tell me the idea how to achieve that

    Thanks in advance

    Hello

    As Dario says you must use a set of model.

    If you want to change the label of the attributes, you can do this by changing the view object (you can do the same in the purpose of the entity and all the viewobject based on this entity is these guidance values) tips of the user interface.

    After that a ModelBundle.properties file will be created automatically.

    The value that you set in the viewobject are those that your query Panel.

    You can create a ModelBundle_de.properties and add the translated labels.

    Kind regards

    Ruben.

  • How to disable WebVPN attributes in the configuration file

    All the attributes of sudden webvpn (illustrated below) make their appearance in my config file? I disabled protocols tunnels webvpn in my default group policy, but that did not help. Anyone has an idea where completely disable it so it will not be displayed in my config file?

    Thank you.

    = part of config which shows webvpn =.

    attributes of Group Policy DfltGrpPolicy

    No banner

    WINS server no

    DNS server no

    DHCP-network-scope no

    VPN-access-hour no

    VPN - connections 3

    VPN-idle-timeout no

    VPN-session-timeout no

    VPN-filter no

    Protocol-tunnel-VPN IPSec

    disable the password-storage

    disable the IP-comp

    Re-xauth disable

    Group-lock no

    disable the PFS

    IPSec-udp disable

    IPSec-udp-port 10000

    Split-tunnel-policy tunnelall

    Split-tunnel-network-list no

    by default no

    Split-dns no

    disable secure authentication unit

    disable authentication of the user

    user-authentication-idle-timeout 30

    disable the IP-phone-bypass

    disable the leap-bypass

    disable the NEM

    Dungeon-client-config backup servers

    the firewall client no

    rule of access-client-none

    WebVPN

    None works

    HTML-content-filter none

    Home page no

    4 Keep-alive-ignore

    gzip http-comp

    no filter

    list of URLS no

    value of customization DfltCustomization

    port - forward, no

    port-forward-name value access to applications

    SSO-Server no

    value of deny message connection succeeded, but because some criteria have not been met, or because of a specific group policy, you are not allowed to use the VPN features. Contact your administrator for more information

    SVC no

    SVC Dungeon-Installer installed

    SVC keepalive no

    generate a new key SVC time no

    method to generate a new key of SVC no

    client of dpd-interval SVC no

    dpd-interval SVC bridge no

    deflate compression of SVC

    Hello

    Try the below command. See that it works.

    attributes of Group Policy DfltGrpPolicy

    No webvpn

    Thank you

    Gilbert

    Rate this post, if this can help!

  • How to define an attribute of the declarative component with the list of options

    12.1.3 jdev

    I'm trying to define a declarative component UOM. It has a text box with a selectOneChoice of the optional codes for this type of unit of MEASURE.

    I have uomType as one of the attributes of my unit of MEASURE. It may be of WEIGHT, VOLUME, LENGTH, etc. Is it possible to provide a list of the channels supported for my uomType? So, when the user uses this component, they can select a type they want in the list, instead of typing in themselves.

    < afc:attribute >
    < afc:attribute - name > uomType < / afc:attribute - name >
    < afc:attribute - class > java.lang.String < / afc:attribute - class >
    < afc: required > true < / afc: required >
    < / afc:attribute >

    Thank you.

    Hello

    Unfortunately the lists are not an option with the declarative elements

    Frank

  • HOW to add an attribute to the existing node?

    Hello

    I have a question - is possible to add a NEW attribute to existing xml node registered in xmltype?

    I found no such a possibility.

    I need to use the update! :)

    I have: < tag > < tag2 / > < tag / >

    I want to have < tag value = 1 > < tag2 / > < tag / >

    THANKS IN ADVANCE! :)

    With insertChildXML:

    SQL> with t as (
      2    select xmltype('') doc
      3    from dual
      4  )
      5  select insertChildXML(doc, '/tag', '@value', 1)
      6  from t
      7  ;
    
    INSERTCHILDXML(DOC,'/TAG','@VA
    --------------------------------------------------------------------------------
    
     
    

    Alternatively, in 11.2.0.3, updated XQuery:

    select xmlquery(
    'copy $d := $doc/tag
     modify ( insert node attribute value {$val} into $d )
     return $d'
     passing t.doc as "doc"
           , 1 as "val"
     returning content
    )
    from t
    ;
    
  • Cannot set attribute of the param element value using javascript in setAttribute

    When adding the items param via createFragment the javascript in setAttribute function does not set the "value" attribute It is necessary to set the nodetext to add this attribute to the value of the param element.

    Second, when using the method of the generated html code defines the 'value' to the innerHTML. HTML code resulting in the display by "Inspect the system" looks like this.

    < parameter id = "myID" > myValue < / param >

    Note: [the element close text < / param > is displayed correctly using inspect, but when using file-> SavePageAs the end text is not saved correctly.] I reported this in another question of moz. support FF.]

    function setparamAttrs (parmID, parmVal)
    {

    var gData = document.createDocumentFragment();
    
     var newNode = document.createElement("param");
     var textStr = document.createTextNode(parmVal);
     newNode.appendChild(textStr);
    
     newNode.setAttribute("id", parmID);
     //newNode.setAttribute("value", parmVal);  // this does not work
     //newNode.setAttribute("innerHTML", parmVal);  //this does not work
    
     gData.appendChild(newNode);
     document.body.appendChild(gData);
    

    }

    However, I was able to retrieve the "value", once it has been added using:

    var val = document.getElementById("parm0").value;)

    getAttribute ("value") does not work either.

    Finally, I added the param elements to my HTML code like this.
    < parameter id = "myID" > myValue < / param >. Then I tried to extract the value using document.getElementById("myID").innerHTML. No text has been returned. When I looked at the HTML document with inspect my HTML param element is displayed as < param id = "myID" > myVal. The closing text of the element has not the same when I use SavePageAs which I mentioned previously.

    Yes, this is the correct way to this code and it works for me without any problem.

  • How to use a UUID type number instead of sequence as a default value in the attribute of the view object?

    Hi all.. I want to use a type UUID number in an attribute of the object from view as default value to generate the unique field... so, how can I generate random uuid?

    Well, the UUID looks like as follows:

    Example 1: 067e6162-3b6f-4ae2-a171-2470b63dff00

    Example 2: 54947df8-0e9e-4471-a2f9-9af509fb5889

    You can play withgetMostSignificantBits() and getLeastSignificantBits() , this is the long values and you can combine them in order to generate BigInteger, as described here:

    https://gist.github.com/berezovskyi/2c4d2a07fa2f35e5e04c

    Then just use this value in the constructor number:

    http://docs.Oracle.com/CD/E12839_01/apirefs.1111/e10655/Oracle/JBO/domain/number.html#number%28Java.math.BigInteger%29

  • How to navigate to the next page based on the value returned by the method call inside the action attribute of the command key.

    How to navigate to the next page based on the value returned by the method call inside the action attribute of the command key.

    I use JDeveloper 12.1.2.0.0

    < af:button id = "tt_b2".

    rendered = "#{attrs.nextRendered} '"

    partialSubmit = 'true '.

    action = "#{attrs.backingBean.nextAction} '"

    Text = "next".

    Disabled = "#{attrs.nextDisabled}" / >

    private static final String NEXT_NAVIGATION_ACTION = "controllerContext.currentViewPort.taskFlowContext.trainModel.getNext";

    public String nextAction() {}

    If (validate()) {}

    updateModel();

    Return NEXT_NAVIGATION_ACTION;

    }

    Returns a null value.

    }

    Use case is made for model train, which is being implemented based on this blog: http://javacollectibles.blogspot.co.UK/2014/10/ADF-train-template.html

    We define a generic action following in the model, but the action must be called under certain conditions, based on the question of whether all validation controls had been passed on no.

    You can do this in two ways:

    1 returnValue = (String) ADFUtils.invokeEL("#{controllerContext.currentViewPort.taskFlowContext.trainModel.getNext}");

    return returnValue;

    2.

    public String getNextTrainStop() {}

    String nextStopAction = null;

    ControllerContext controllerContext = ControllerContext.getInstance ();

    ViewPortContext currentViewPortCtx = controllerContext.getCurrentViewPort ();

    TaskFlowContext taskFlowCtx = currentViewPortCtx.getTaskFlowContext ();

    TaskFlowTrainModel taskFlowTrainModel = taskFlowCtx.getTaskFlowTrainModel ();

    TaskFlowTrainStopModel currentStop = taskFlowTrainModel.getCurrentStop ();

    Terminus of TaskFlowTrainStopModel = taskFlowTrainModel.getNextStop (currentStop);

    nextStopAction = nextStop.getOutcome ();

    _logger.fine ("train, next stop:"+ nextStopAction ");

    Return nextStopAction;

    }

  • How to remove the value of the XML attribute in the Indesign file with javascript

    Hi all

    How to remove the value of the XML attribute in the Indesign file.

    1.jpg

    What error is this?

    in any case try this as well (one another),

    var myDoc = app.activeDocument;
    attrDelete(myDoc);
    function attrDelete(elm)
    {
        for (var i = 0; i < elm.xmlElements.length; i++)
        {
            try{
                for(j=0; j
    

    Vandy

  • How to get the attributes from the list of values

    Hello

    I have two display objects, of 'Customer' and 'CustomerDetails '.
    'Client' view, has the attribute 'CustomerId' I've defined as LOV with view of 'CustomerDetails '.
    Like this:
    <ListBinding
        Name="LOV_CustomerId"
        ListVOName="CustomerDetailsView1"
        ListRangeSize="-1"
        NullValueFlag="start"
        NullValueId="${adfBundle['oracle.javatools.resourcebundle.SystemBundle']['NULL_VALUE_RESID']}"
        MRUCount="0">
        <AttrArray Name="AttrNames">
          <Item Value="CustomerId"/>
        </AttrArray>
        <AttrArray Name="ListAttrNames">
          <Item Value="Id"/>
        </AttrArray>
        <AttrArray Name="ListDisplayAttrNames">
          <Item Value="Name"/>
        </AttrArray>
        <DisplayCriteria/>
      </ListBinding>
    I hung out in the soc on my page
    <af:selectOneChoice value="#{bindings.CustomerId.inputValue}" label="#{bindings.CustomerId.label}"
          required="#{bindings.CustomerId.hints.mandatory}"
           shortDesc="#{bindings.CustomerId.hints.tooltip}" id="soc16" autoSubmit="true">
     <f:selectItems value="#{bindings.CustomerId.items}" id="si16"/>
    </af:selectOneChoice>
    In the 'CustomerDetails' view, there is also "address" attribute.
    I would like to get the address according to the ID.

    How could I get through links?
    or in another way.

    Thank you!!

    Hello

    You want to display the address that is present in VO from customer to customer details?

    If so,.

    Perform the following steps:

    1 - Create a transient with string type attribute customer details VO (always updated).
    2 - I hope you have an attribute customer id here attribute where you created LOV. When LOV created in create list of values jump towards the top in the list of return values assign the value of the address in the transitional attribute.

    If you put this attribute on the user interface you can see the customer address id value correspondent.

    Thank you
    Prateek

  • No idea how to loop and add the value to the attribute of the xml node?

    I work on a lot of flattening of project using a watched folder.

    I have a process parent to locate the directory and call a sub-process to flatten PDF files.

    I want to write the directory failed to XML.

    If there are several directory failed locations and if I want to add it to the node, he doesn't let me do.

    If I set the Xpath location like/process_data/outputXML/flattenDirectoryRequestMessage/failureFileLocation[x]/@path it gives me invalid character exception. I use 'x' for looping and incrementing.

    If I do not use the [x]. The directory is overwritten.

    No idea how loop and add all the directories failed to attribute of the xml node?

    I understand that you can not browse the xml code to assign the value at each node. Rather you can assign only one time to the node.

    I realized that it is not possible to do it this way. Then concatenate it as strings, and then attach to the xml once.

  • Table of attributes in the XML element and the element values. Is this possible?

    I use BI Publisher generator model for Word. I'm using Word 2007 and the patch 9821068 generator model.

    I'm trying to create a table using the table Wizard. The values in the column must be based on the attributes of the element and the element values. I have no control over the incoming data.

    Given the following XML:

    <? XML version = "1.0" encoding = "UTF-8"? >
    < valuesOverTime type = "fromServer" >
    < name aValue = "xyz" date = "2010-07-21" time = "" 15: 55:26 ' > 2 < / aValue > "
    < name aValue = 'abc' date = "2010-07-21" time = "" 15: 55:26 ' > 0 < / aValue > "
    < name aValue = "xyz" date = "2010-07-21" time = "" 15: 55:26 "> 42 < / aValue >"
    < name aValue = 'abc' date = "2010-07-21" time = "" 15: 55:26 "> 100 < / aValue >"
    < name aValue = "xyz" date = "2010-07-21" time = "" 15: 55:26 "> 17 < / aValue >"
    < name aValue = 'abc' date = "2010-07-21" time = "" 15: 55:26 ' > 0 < / aValue > "
    < name aValue = "xyz" date = "2010-07-21" time = "" 15: 55:26 "> 1 < / aValue >"
    < / valuesOverTime >

    Table I need should look like this:

    name date time aValue
    XYZ-2010-07-21 15:55:26 2
    ABC-2010-07-21 15:55:26 0
    XYZ-2010-07-21 15:55:26 42

    So far, that I can understand it.

    Any suggestions?

    Thank you
    -Matt
    
      
    
    
  • How to map the entered value of attribute column to another attribute in the table for each row.

    Hi Experts ADF,

    JDev 12 c.

    I create a button and a table below. If the user clicks on the button create, I invoke CreateInsert. The new line now appears as an editable fields.

    So I suppose I have a column that is displayed in editable mode. If the user enters values in that. Has another column B whose value is not displayed in the UI must have the same value as the column.

    This occurs for each row added. During the click on save if user entered 2 in column A, then the value in column B must be same 2.

    Thank you

    Roy

    There is more than one way, for example:

    Generate ViewRowImpl Java class (with generate audited accessors) you will get for an attribute setter.

    Change the Set accessor to set the attribute B (IE, calling setAttribute ("B", value)) after setting a value

    OR, write valueChangeListener for inputText representative and set the B attribute to the same value

  • How to create elements of the checkbox on the form of tables

    I use the Application Express 4.2.1.00.08
    We currently have a spreadsheet that is who I am trying to replace application using APEX.

    I have loaded the spreadsheet into a table and have created a tabular presentation using the tabular presentation wizard who created the field in the form of text fields.

    The table has 38 columns in total, so I am trying to retrieve the columns to fit the screen.

    Most of the columns in the spreadsheet contain just the value 1 or null, so I want to make these fields check box so that they are checked if the value of the field is 1 and not controlled if the value is null. If the user selects the checkbox on the ground so I want to write a 1 in the table.

    Can you suggest I do this because several things that I have tried don't seem to work.

    Any suggestions or links to the doc on how to do that would be great.

    The structure of the table is the following:
    Name Null? Type
    ----------------------------------------- -------- ----------------------------
    IDENTIFICATION NUMBER
    FIELDNAME VARCHAR2 (30)
    ENTITY_CATEGORY VARCHAR2 (30)
    ATRIBUTE_GROUP VARCHAR2 (30)
    MASTER_SOURCE_SYSTEM VARCHAR2 (30)
    ENTERED_BY VARCHAR2 (30)
    DESCRIPTION VARCHAR2 (30)
    EXAMPLE_DATA VARCHAR2 (30)
    10891 VARCHAR2 (1)
    VARCHAR2 (1) 11072
    10892 VARCHAR2 (1)
    10487 VARCHAR2 (1)
    11065 VARCHAR2 (1)
    VARCHAR2 (1) 11078
    11066 VARCHAR2 (1)
    11067 VARCHAR2 (1)
    VARCHAR2 (1) 11061
    VARCHAR2 (1) 11062
    11063 VARCHAR2 (1)
    11064 VARCHAR2 (1)
    11079 VARCHAR2 (1)
    VARCHAR2 (1) 11057
    VARCHAR2 (1) 10520
    11058 VARCHAR2 (1)
    VARCHAR2 (1) 11056
    1262 VARCHAR2 (1)
    11070 VARCHAR2 (1)
    11059 VARCHAR2 (1)
    11060 VARCHAR2 (1)
    11071 VARCHAR2 (1)
    VARCHAR2 (1) 10819
    11069 VARCHAR2 (1)
    VARCHAR2 (1) 11068
    11074 VARCHAR2 (1)
    11075 VARCHAR2 (1)
    11076 VARCHAR2 (1)
    11077 VARCHAR2 (1)
    11073 VARCHAR2 (1)

    Published by: Kay Richards on June 7, 2013 16:51

    Published by: Kay Richards on June 7, 2013 17:14

    Click on the shape of table on the edit page

    go to the report attributes tab

    you will find the list of form elements

    now, click the icon to change the required column (small pencil icon).

    go to the tab column attributes, change the display as simple field check box.

    Then go to the values tab list.

    you will find the list of values definition text box just add 1 then click on apply changes.

    Run the page, you are gud to go.

    NULL is the default if the checkbox is in a disabled state, just use 1 in the list of values.

    Kind regards

    Mohan.

  • How to use the VO attribute in the URI of the destination link added in customization

    Hello

    The notification of approval of application, I need to add a link to a custom page. This custom page requires the id of the request as a parameter header.
    For the page, we have a function. The function is called in the link.

    If I add this link on the row requisiton area, it works because I can just refer to the VO attribute and the value is transferred.
    But this means that the link is placed on each line.
    The user wants to see this link only once.

    So I tried to add a link on another level.
    The problem seems to be that I can't reference requisiton header value in the URI of destination when the link is created out of the box 'lines '.
    The value IS available and displays in any element of Message Style text create in customization.
    But in a link element, I don't know how to get the value of the URI of the destination.

    Can someone help me please?
    What is the correct syntax to do this?

    Thank you
    Ronny

    Hi Ronny

    Maybe you need to explicitly specify the Name property of the VO on your item link, depending on which area it is in.

    Thank you very much

    Richard

Maybe you are looking for