Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to loop over in Xquery and compare the values within loops

RAMMIIMay 24 2017 — edited Jun 11 2017

I am new to Xquery , i have something tricky requirement.

Below is the sample xml for my requirement and tabled the values below. There are four(can be more ) titlcodes in each class type within network, from this i would like to form a key for each title code combination of  two networks and put them under titlecode range and max repeatable key will be at  Range at class. Provide input and expected xml also below.

Any pointers how to achieve that would be helpful, if not through x query is there any other approach to do this?

Classtype =23/ title codes         

AA

AB

key

P1

100

100

100_100

P2

  80

50

80_50

P3

80

80

80_80

P4

80

50

80_50

Input :

<root>

<ns1:Network>

    <ns1:description>AA</ns1:description>

    <ns1:classType>

        <ns1:class>23</ns1:class>

        <ns1:RangeAtClass>100</ns1:RangeAtClass>

        <ns1:title>                  

            <ns1:titleCode>P1</ns1:titleCode>                  

            <ns1:titleRange>100</ns1:titleRange>      

        </ns1:title>

        <ns1:title>

            <ns1:titleCode>P2</ns1:titleCode>

            <ns1:titleRange>80</ns1:titleRange>

        </ns1:title>

        <ns1:title>

            <ns1:titleCode>P3</ns1:titleCode>

            <ns1:titleRange>80</ns1:titleRange>

        </ns1:title>

        <ns1:title>

            <ns1:titleCode>P4</ns1:titleCode>

            <ns1:titleRange>80</ns1:titleRange>

        </ns1:title>      

    </ns1:classType>

</ns1:Network>

<ns1:Network>

    <ns1:description>AB</ns1:description>

    <ns1:classType>

        <ns1:class>23</ns1:class>

        <ns1:RangeAtClass>100%</ns1:RangeAtClass>

        <ns1:title>                  

            <ns1:titleCode>P1</ns1:titleCode>                  

            <ns1:titleRange>100</ns1:titleRange>      

        </ns1:title>

        <ns1:title>

            <ns1:titleCode>P2</ns1:titleCode>

            <ns1:titleRange>50</ns1:titleRange>

        </ns1:title>

        <ns1:title>

            <ns1:titleCode>P3</ns1:titleCode>

            <ns1:titleRange>80</ns1:titleRange>

        </ns1:title>

        <ns1:title>

            <ns1:titleCode>P4</ns1:titleCode>

            <ns1:titleRange>50</ns1:titleRange>

        </ns1:title>      

     </ns1:classType>  

</ns1:Network>

</root>

Expected OUTPUT:

<root>

<ns1:Network>

                <ns1:description>AA</ns1:description>

                <ns1:classType>

                                <ns1:class>23</ns1:class>

                                <ns1:RangeAtClass>80</ns1:RangeAtClass>   (first value of max occurrence key)

                                <ns1:title>                                                            

                                                <ns1:titleCode>P1</ns1:titleCode>                                                                      

                                                <ns1:titleRange>100_100</ns1:titleRange>                       

                                </ns1:title>

                                <ns1:title>

                                                <ns1:titleCode>P2</ns1:titleCode>

                                                <ns1:titleRange>80_50</ns1:titleRange>

                                </ns1:title>

                                <ns1:title>

                                                <ns1:titleCode>P3</ns1:titleCode>

                                                <ns1:titleRange>80_80</ns1:titleRange>

                                </ns1:title>

                                <ns1:title>

                                                <ns1:titleCode>P4</ns1:titleCode>

                                                <ns1:titleRange>80_50</ns1:titleRange>

                                </ns1:title>                      

                </ns1:classType>

</ns1:Network>

<ns1:Network>

                <ns1:description>AA</ns1:description>

                <ns1:classType>

                                <ns1:class>23</ns1:class>

                                <ns1:RangeAtClass>50</ns1:RangeAtClass> (second value of max occurrence key)

                                <ns1:title>                                                            

                                                <ns1:titleCode>P1</ns1:titleCode>                                                                      

                                                <ns1:titleRange>100_100</ns1:titleRange>                       

                                </ns1:title>

                                <ns1:title>

                                                <ns1:titleCode>P2</ns1:titleCode>

                                                <ns1:titleRange>80_50</ns1:titleRange>

                                </ns1:title>

                                <ns1:title>

                                                <ns1:titleCode>P3</ns1:titleCode>

                                                <ns1:titleRange>80_80</ns1:titleRange>

                                </ns1:title>

                                <ns1:title>

                                                <ns1:titleCode>P4</ns1:titleCode>

                                                <ns1:titleRange>80_50</ns1:titleRange>

                                </ns1:title>                      

                 </ns1:classType>          

</ns1:Network>

</root>

Comments

SureshDooly-Oracle

$oerr ora 12154
ORA-12154: TNS:could not resolve the connect identifier specified

Cause: A connection to a database or other service was requested using a connect identifier, and the connect identifier specified could not be resolved into a connect descriptor using one of the naming methods configured.
For example, if the type of connect identifier used was a net service name then the net service name could not be found in a naming method repository, or the repository could not be located or reached.

Please cross-check the below:

Action: The following actions may be appropriate:
If you are using local naming (tnsnames.ora file):
Make sure that TNSNAMES is listed as one of the values of the names.directory_path parameter in the sqlnet.ora Oracle Net profile.
Verify that a tnsnames.ora file exists and is in the proper directory and is accessible.
Check that the net service name used as the connect identifier exists in the tnsnames.ora file.
Make sure there are no syntax errors anywhere in the tnsnames.ora file. Look for unmatched parentheses or stray characters. Errors in a tnsnames.ora file may make it unusable.

1 - 1
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jul 9 2017
Added on May 24 2017
5 comments
14,627 views