XPath max function

Hi all,
I'm a beginner working with XPath expressions.
I have a xml document 'test.xml' with the following contents.
<?xml version="1.0" encoding="UTF-8"?>
<ICRI xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.orswegimoarmada.es/ORSWE/ICRI
http://www.orswegimoarmada.es/ORSWE/XSD/ICRI/ICRI.xsd"
xmlns="http://www.orswegimoarmada.es/ORSWE/ICRI">
<ID>ICRI.Prueba.DocPrueba1.2006.11.15-09.19.01</ID>
<NombreRecurso>DocPrueba1</NombreRecurso>
<TipoRecurso>Documento Técnico</TipoRecurso>
<Descripcion>Documento de ejemplo.</Descripcion>
<ExtensionRecurso/>
<VersionRecurso>1.0</VersionRecurso>
<Estado>En Proceso</Estado>
<NivelSeguridad>NATO UNCLASSIFIED</NivelSeguridad>
<Entornos/>
<PalabrasClave/>
<Sinonimos/>
<Modificaciones>
<Modificacion>
<Usuario>demoadminpro</Usuario>
<FechaHora>2006.11.15-09.19.01</FechaHora>
<Secuencia>1</Secuencia>
<EnlaceRecurso>/ORSWE/Proyectos/Prueba/Documento Técnico/DocPrueba1.2006.11.15-09.19.01.xml</EnlaceRecurso>
</Modificacion>
<Modificacion>
<Usuario>demoadminpro</Usuario>
<FechaHora>2006.11.15-09.20.01</FechaHora>
<Secuencia>2</Secuencia>
<EnlaceRecurso>/ORSWE/Proyectos/Prueba/Documento Técnico/DocPrueba1.2006.11.15-09.20.01.xml</EnlaceRecurso>
</Modificacion>
<Modificacion>
<Usuario>demoadminpro</Usuario>
<FechaHora>2006.11.15-09.21.01</FechaHora>
<Secuencia>3</Secuencia>
<EnlaceRecurso>/ORSWE/Proyectos/Prueba/Documento Técnico/DocPrueba1.2006.11.15-09.21.01.xml</EnlaceRecurso>
</Modificacion>
</Modificaciones>
</ICRI>
I use the code to obtain information about xml.
SELECT extractValue(value(d), '/ICRI/NombreRecurso', 'xmlns="http://www.orswegimoarmada.es/ORSWE/ICRI"') NOMBRERECURSO,
       extractValue(value(d), '/ICRI/TipoRecurso', 'xmlns="http://www.orswegimoarmada.es/ORSWE/ICRI"') TIPORECURSO,
        extractValue(value(d), '/ICRI/VersionRecurso', 'xmlns="http://www.orswegimoarmada.es/ORSWE/ICRI"') VERSIONRECURSO,
        extractValue(value(d), '/ICRI/Descripcion', 'xmlns="http://www.orswegimoarmada.es/ORSWE/ICRI"') DESCRIPCION,
        extractValue(value(d), '/ICRI/Modificaciones/Modificacion/Secuencia', 'xmlns="http://www.orswegimoarmada.es/ORSWE/ICRI"') SECUENCIA
FROM RESOURCE_VIEW r, table(xmlsequence(extract(r.res, '/r:Resource/r:Contents/i:ICRI', 'xmlns:r="http://xmlns.oracle.com/xdb/XDBResource.xsd" xmlns:i="http://www.orswegimoarmada.es/ORSWE/ICRI"'))) d
WHERE r.any_path='test.xml'But the element Secuencia has several values and I only need to obtain the max of this values. I think, XPath max function can resolve this issue, but I don't know how do I do this?. Is it possible?
Thanks in advance,
David.

Well, I am desperate :-(((
I am trying to extend the early query, now, r.any_path must be obtained from another table that it is another registered schema also.
The folowing is a piece of this query:
SELECT
extractValue(value(di), '/ICRI/NombreRecurso', 'xmlns="http://www.orswegimoarmada.es/ORSWE/ICRI"') NOMBRERECURSO,
extractValue(value(di), '/ICRI/TipoRecurso', 'xmlns="http://www.orswegimoarmada.es/ORSWE/ICRI"') TIPORECURSO,
extractValue(value(di), '/ICRI/VersionRecurso', 'xmlns="http://www.orswegimoarmada.es/ORSWE/ICRI"') VERSIONRECURSO,
extractValue(value(di), '/ICRI/Descripcion', 'xmlns="http://www.orswegimoarmada.es/ORSWE/ICRI"') DESCRIPCION
FROM RESOURCE_VIEW r,
     table(xmlsequence(extract(r.res, '/r:Resource/r:Contents/i:ICRI', 'xmlns:r="http://xmlns.oracle.com/xdb/XDBResource.xsd" xmlns:i="http://www.orswegimoarmada.es/ORSWE/ICRI"'))) di
WHERE
    r.any_path IN 
    (select extractValue(value(t), '/InfoEntradaGeneral/EnlaceICRI', 'xmlns="http://www.orswegimoarmada.es/ORSWE/PlantillaProyecto')
     FROM PLANTILLAPROYECTO p, table(xmlsequence(extract(p.object_value, '/PlantillaProyecto/Proceso/Pasos/Paso[@IdPaso="0"]/Actividades/Actividad[@IdActividad="1"]/EntradasActividad/EntradasGenerales/InfoEntradaGeneral'))) t
     WHERE existsNode(p.object_value, '/PlantillaProyecto/DetallesProyecto[NombreProyecto="Prueba"]')=1);Now, Oracle only shows me a register when the query must be three.
The query
select extractValue(value(t), '/InfoEntradaGeneral/EnlaceICRI', 'xmlns="http://www.orswegimoarmada.es/ORSWE/PlantillaProyecto')
FROM PLANTILLAPROYECTO p, table(xmlsequence(extract(p.object_value, '/PlantillaProyecto/Proceso/Pasos/Paso[@IdPaso="0"]/Actividades/Actividad[@IdActividad="1"]/EntradasActividad/EntradasGenerales/InfoEntradaGeneral'))) t
WHERE existsNode(p.object_value, '/PlantillaProyecto/DetallesProyecto[NombreProyecto="Prueba"]')=1);returns several values, for instance:
1. test.xml
2. test1.xml
3. test2.xml
Why does not it work?. I suppose that the query is correct.
I try the same with relational tables and it works fine.
Query SELECT B.COLUMN2 FROM B WHERE B.COLUMN1 IN (SELECT COLUMN1 FROM A returns several values from A and shows the right values from B.
Please, Could someone to help me?
Thanks in advance,
David.

Similar Messages

  • How to Avoid Errors in Max Function When Data Contains Blank Cells

    I have a column with duration values. However, it also contains some blank cells. These "blank cells" have formulas in them, but as the cells they reference too are blank the formula doesn't produce a result.>/p>
    I want to get the max value from this column. When I simply do =MAX(column-name) I get an error, presumably because some of the cells are blank. This table is going to be highly dynamic, so I don't want to limit the range of the MAX() function to only those cells with values.
    So does anyone know a solution for this, please? If I was some how able to create a formula which returned the range of cells with actual values, then I could use that in the MAX() function. Or, if I could somehow tell the MAX() function to ignore blank cells, but I'm not sure either of these are possible.
    Thanks,
    Nic

    I don't see a problem with "blank" (null string) cells mixed with duration cells.  MAX works fine with this mix of cells. But if the "blank" cells are numbers, not text, that gives an error.
    A formula always produces a result. A formula cannot result in a blank cell. The closest you can get to "blank" is a null string (the result of two quotes next to each other with nothing between them) . So the question is, what is the result that you are calling "blank"?

  • MAX function

    Hi Everyone,
    Am aware of the following flavors of MAX function
    1) choose MAX from the folders/fields list (selected items tab)
    2) create calculation using: MAX keep dense
    3) create calculation using: MAX analytic function
    questions, pls:
    ===========
    a) with MAX regular, MAX keep dense, MAX - analytic function
    is it necessary to sort it using tools/sort - choose fields to sort by?
    or does the data get sorted due to the ORDER BY clause in MAX used in a calculation
    b) how to understand the diff. bet. MAX keep dense and MAX - analytic function
    1) i understand that analytic functions are applied after detail row processing
    does MAX keep dense calculation happen during detail row processing?
    2) how did you know to advise when to use MAX keep dense, and when to use MAX - analytic function?
    tx for your ideas and assistance, sandra

    Hi,
    a) with MAX regular, MAX keep dense, MAX - analytic function is it necessary to sort it using tools/sort - choose fields to sort by? or does the data get sorted due to the ORDER BY clause in MAX used in a calculationIt is only necessary to use a sort if you want to have the rows returned in a specific order. The order by in the max calculation defines the maximum within the group or window. It may affect the order the rows are returned, but if it does this is not guaranteed and you should use a sort on the main query.
    b) how to understand the diff. bet. MAX keep dense and MAX - analytic function
    1) i understand that analytic functions are applied after detail row processing does MAX keep dense calculation happen during detail row processing?Yes
    2) how did you know to advise when to use MAX keep dense, and when to use MAX - analytic function?In general, if you want the result on a single row, so you have one row for each group then you should use the aggregate max. If you want to use the same max on all the rows in the window (defined by the partition) then use the analytic max.
    Rod West

  • Using max function in PL/SQL

    VERY URGENT...
    Am new to oracle...
    I've written a package that display gif images in form of histogram/bar chart. using html,
    I need to use max function to display values proportionately.
    please help. i need to complete this assignment by 2/9/00 by 10.00 am at the latest. I've half written a function but I don't know if there's a simpler way fo doing this. html enabled

    First of all Thanks to all gentlemen who replied ..many thanks ...
    Tried the ROW_NUMBER() option but still it is taking time...have given output for the query and tkprof results as well. Even when it doesn't fetch any record ( this is a valid cased because the input header id doesn't have any workflow request submitted & hence no entry in the wf_items table)..then also see the time it has taken.
    Looked at the RANK & DENSE_RANK options which were suggested..but it is still taking time..
    Any further suggestions or ideas as to how this could be resolved..
    SELECT 'Y', 'Y', ITEM_KEY
    FROM
    ( SELECT ITEM_KEY, ROW_NUMBER() OVER(ORDER BY BEGIN_DATE DESC) RN FROM
    WF_ITEMS WHERE ITEM_TYPE = 'xxxxzzzz' AND ROOT_ACTIVITY = 'START_REQUESTS'
    AND SUBSTR(ITEM_KEY,1,INSTR(ITEM_KEY,'-') - 1) = :B1
    ) T WHERE RN <= 1
    call count cpu elapsed disk query current rows
    Parse 0 0.00 0.00 0 0 0 0
    Execute 1 0.00 1.57 0 0 0 0
    Fetch 1 8700.00 544968.73 8180 8185 0 0
    total 2 8700.00 544970.30 8180 8185 0 0
    many thanks

  • Regarding MAX() function

    Hi,
    I am having table A. I have few records in the table A. Database version : 9.2
    ID name deleted
    2 XYZ N
    3 ABD N
    4 GJK N
    5 GJK N
    6 HGY N
    7 YJG N
    8 PIN N
    9 BMF N
    10 OLG N
    I used the following query...
    SELECT MAX(ID) FROM A WHERE DELETED='N';
    It was worked fine until now....
    Now i used the same query...
    But the result is
    MAX(ID)
    9
    Please help me... What is the reason?
    I want the correct result...
    Thanks in advance....                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Kamran Agayev A. wrote:
    Yes you can use TO_NUMBER inside MAX function and it will not give any error in the futureHave you tested it?
    SQL> create table a (id,name,deleted)
      2  as
      3  select '2', 'XYZ', 'N' from dual union all
      4  select '3', 'ABD', 'N' from dual union all
      5  select '4', 'GJK', 'N' from dual union all
      6  select '5', 'GJK', 'N' from dual union all
      7  select '6', 'HGY', 'N' from dual union all
      8  select '7', 'YJG', 'N' from dual union all
      9  select '8', 'PIN', 'N' from dual union all
    10  select '9', 'BMF', 'N' from dual union all
    11  select '10', 'OLG', 'N' from dual
    12  /
    Tabel is aangemaakt.
    SQL> select max(id)
      2    from a
      3   where deleted = 'N'
      4  /
    MA
    9
    1 rij is geselecteerd.
    SQL> select max(to_number(id))
      2    from a
      3   where deleted = 'N'
      4  /
                        MAX(TO_NUMBER(ID))
                                        10
    1 rij is geselecteerd.
    SQL> insert into a values ('2A', 'ABC', 'N')
      2  /
    1 rij is aangemaakt.
    SQL> select max(to_number(id))
      2    from a
      3   where deleted = 'N'
      4  /
    select max(to_number(id))
    FOUT in regel 1:
    .ORA-01722: invalid numberRegards,
    Rob.

  • Use of MAX function

    Hi,
    I am using parent-child hierarchy and in my reports I want to show Max(hierarchy_level). When I use the function MAX directly in the report it works fine in every way. But I want to have this kind of column in the BI Server presentation catalog so the user does not need to add MAX in Analysis/Answers (this is 11g). Normally this would imply a Max(hierarchy_level) as a logical function, but in the BI Server it is not allowed with MAX function in the logical function so it does not work.
    The hierarchy level is just a column from a dimension table and creating it as a fact column is not a very good solution. I also tried to solve this in many different ways, but only the MAX funtion in Analysis/Answers allways give the correct result. Used in combination with other dimensions etc. I want the exact same behaviour as I get when using MAX in analysis.
    Any good ideas to solve this? Is there another function in the BI Server that works the same way as MAX ?

    Very often, about a primary key, see for example our italian accounting application (our VAT invoices:fatture IVA) ), where the holes might be a problem.
    Yes Rosario, of course I know that, and that's why I said "in this scenario" : if primary key is the only purpose, I don't think holes could be a problem.
    Buona giornata anche a te.

  • Jar-file for XPath extension functions

    Hi all,
    can anyone tell me which jar-file contains the class for the following xpath extension function / method:
    oracle.tip.pc.services.functions.Xpath20.currentDate
    I need this for an ant xsl validation which runs without JDev.
    Thanks in advance, Ingo

    When you go to :
    <ORACLE_HOME>/bpel/system/config
    you will find the file : xpath-functions.xml
    In this file you will see :
        <function id="getCurrentDate" arity="0">
            <classname>com.collaxa.cube.xml.xpath.functions.datetime.GetCurrentDateFunction</classname>
            <comment>
            <![CDATA[This function returns current date as string.
            <p/>
            The signature of this function is <i>ora:getCurrentDate('format'?)</i>.  The argument (optional) specifies a string formatted accoding to java.text.SimpleDateFormat format.]]>
            </comment>
            <property id="namespace-uri">
                <value>http://schemas.oracle.com/xpath/extension</value>
                <comment>Namespace URI for this function</comment>
            </property>
            <property id="namespace-prefix">
                <value>ora</value>
                <comment>Namespace prefix for this function</comment>
            </property>
        </function>This classname can be found in the orabpel.jar
    sorry..wrong function..
    Message was edited by:
    Eric Elzinga (IT-Eye)

  • Use of MAX function in Query Designer

    Dear all,
    i want to create a report that gives ONE line per period that holds the MAX of several lines per period. So NO addition of the KF but just one line item.
    I tried to use the MAX function and/or MAX drop-down boxes via properties on KF,
    but they all provide the wrong result (mostly the MAX after summaction of the KF).
    Any ideas ??
    Greetz,
    Herman

    Hi Herman
        Please check the KF infoobject property which might have been set to Summation.  You need to change the property of the KF to MAX if you wish to have MAX value. 
        Hope this might be helpful to you
    Thanks
    Kishore Kusupati

  • How to use MAX function in SSAS MDX Query

    I want to run this Query with MAX Condition on LAST_DATA_UPDATE Column .

    Hi Ashishsingh,
    According to your description, you want to know how to use MAX function in SQL Server Analysis Services MDX Query, right? In this case, please refer to the link below which describe the syntax and sample of MDX function.
    http://technet.microsoft.com/en-us/library/ms145601.aspx
    http://www.mdxpert.com/Functions/MDXFunction.aspx?f=64
    Hope this helps.
    Regards,
    Charlie Liao
    TechNet Community Support

  • Oracle:how to use max() function in case expression

    how to use max() function in case expression, Please explain with any example

    Hope this helps and should be self explanatory
    with t as
    (select 1 col,100 col2 from dual union
    select 2 ,100 from dual union
    select 2 ,200 from dual union
    select 3,100  from dual union
    select 3,200  from dual  )
    select col, case when max(col2)=100 then 'with 100 range'
    when  max(col2)=200 then 'with 200 range' end  from t group by col

  • How to use MAX() function with date field

    Hi Frzz,
    I have created a Graphical calculation view in which i have multiple records for each employee with different dates. But my requirement is to take the records which have maximum date.
    I have converted the date into Integer and applied the MAX() function. But still am getting multiple records.
    Is there is any other way we can achieve this requirement in Graphical Calculation view??  Your suggestion will really help me.
    Thank  you.
    Krishna.

    Hmm... what have you tried out so far?
    Look, I took the effort and created a little example, just for you
    Assume we have a table that contains the logon dates of users.
    Every line contains the logon date and some info on the user.
    Very much like a not-normalized log file could look like.
    Now, the output we want is: one line per user with the most current logon time.
    Not too difficult:
    1. Have a aggregation node that gives you the distinct user details - one line for every user:
    2. Have another aggregation node that gives you the last (MAX) logon date per user:
    Finally you do a 1:1 join on the USER_ID and map the result to the output.
    Easy as pie
    - Lars

  • Use COUNT or MAX functions inside of a query, and you have no data found

    I'm writing a query with a COUNT and a MAX function.
        SELECT  li.id
                 , MAX(m.display_date)
                , COUNT(*)
         FROM li JOIN m  ON (m.LIID=li.LIID)
        WHERE m.DISPLAY_DATE < SYSDATE - 7
        GROUP BY  li.id;I would like to write a query that returns always a row foe each row in the table li.
    If there are no records with the condition "WHERE m.DISPLAY_DATE < SYSDATE - 7", I would like to have a row with
    - COUNT(*) = 0
    - MAX(m.display_date) = TO_DATE('2010-06-08', 'YYYY-MM-DD'

    user600979 wrote:
    I'm writing a query with a COUNT and a MAX function.
    SELECT  li.id
    , MAX(m.display_date)
    , COUNT(*)
    FROM li JOIN m  ON (m.LIID=li.LIID)
    WHERE m.DISPLAY_DATE < SYSDATE - 7
    GROUP BY  li.id;I would like to write a query that returns always a row foe each row in the table li.
    If there are no records with the condition "WHERE m.DISPLAY_DATE < SYSDATE - 7", I would like to have a row with
    - COUNT(*) = 0
    - MAX(m.display_date) = TO_DATE('2010-06-08', 'YYYY-MM-DD'In that case tell me what do you want to display in the ID column. That is the first column?

  • Using Max Function in View Criteria

    Hi
    I am having a requirement where by i need to make use of max function in view criteria but not able to see any such option. Can someone please help me over it. Here is the requirement.
    In table i will be having multiple rows for an employee and i need to pick latest row based on a column say request_id For e.g.
    Emp RequestId
    A 1
    A 2
    A 3
    A 4
    So if i pass the employee id i should get Row Number 4. In simple SQL language I want something like this
    select * from emp where empid=A and requestid=( select max(requestid) from emp where empid=A)
    Just wanted to know is there any approach that i can use to do all this as part of View Criteria or any other way.
    Any help is appreciated!!!
    Thanks
    AJ

    One way is this -
    1)https://blogs.oracle.com/adf/entry/using_groovy_aggregate_functions_in (You might need to create a self-referencing VL for this , try if it works using a ViewAccessor too)
    OR
    Order by RequestId descending in your SQL for the VO if thats ok , then have the ViewCriteria for the EmpId and programmatically pickup the first row...

  • Problem with max function in air

    Hello ,how are you,I write this query : [b]SELECT *, max(trackerId) FROM  sessiontracker [/b]in
    sqlite manager and it works ,but when I use it in Air application  ,it send me back this error:
    ReferenceError: Error #1056: Cannot create property max(trackerId) on
    com.afarinesh.models.SessionTracke
    ,I guess that Actionscript 3 can not pars max function.
    I appreciate your help

    Hello,
    AIR does support max function. Please see Page 1067 of the actionscript developer's guide, which can be download from http://help.adobe.com/en_US/as3/dev/as3_devguide.pdf. And I tried the max function in my AIR application: create a table, insert some records into the table, and use the "select *, max(column) from table". It works fine.
    I noticed your error is the ReferenceError and related to some AS class. So I am not sure if you use any ORM tool. If so, the issue may be caused by the use of the tool. Please check the configuration and usage of the tool.
    Thanks,
    Yang

  • Max value without using max() function

    Hi
    Is there any way to get the max value from a table without using MAX() function
    Thanks

    well if you think about it i'm sure you'll find a solution
    what does max(field) means, it simply is the value of the field where no other value of the same field that is > than this value exists.
    consider the following :
    table TAB(
    fld NUMBER(5));
    translate the logic and you'll have
    select a.fld from TAB a where NOT EXISTS(select b.fld from TAB b where b.fld>a.fld) and rownum=1;
    of course there are better ways i'm sure, you'll just have to figure'em out.

Maybe you are looking for

  • Can I un-do a restore - I really need the 77 pictures and video's bad - and I have not done a backup in 45 days

    Help - I somehow did a restore on my iPhone and have lost all my pictures!  Can this be undone??

  • Render take forever on HD 1920 x 1080

    I am trying to reduce my time waiting for rendering get done for preview only. I changed to to unlimited the red line change to orange. When i play to preview. Screen appear warning to increase speed or close sequence or etc. Still too slow. Is there

  • Do Java interfaces have automatic reference counting?

    I'm actually a Delphi developer trying to understand interfaces and I'm curious about the way Java implements them. Here is a simple Delphi psuedo-code snippet: var // interface variable Intf : IInterface; // object reference variable Car : TCar; beg

  • Genius exporting idea - YES OR NO?

    I just had a brilliant idea about exporting and I can't wait to share it with you guys so you can tell me if I'm really as smart as I think I am or if I'm just plain dumb and I'm missing something. So I've got a bunch of movies, already edited, all I

  • Database Error is comming in the code

    Hi, When i am running this java class then i am fetiching all the values from database table to the CSV file then i am getting the following database error. import java.io.FileWriter; import java.sql.Connection; import java.sql.ResultSet; import java