Count number of elements

Dear All,
probably there is somethin wrong in how I use the xmlsequence...
I have a table called XML_WORD with a fiels with XML Docs called XML_CONTENT
As you see what I want to try is to count the number of elements into a certain node...
What is wrong in the statement I wrote?
Thanks a lot and hope this will solve my problem with XML_SEQUENCE.
Stefano
SQL> desc XML_WORD
Name Null? Type
ID NUMBER
WORD_ID CHAR(40)
LEMMA CHAR(60)
XML_CONTENT SYS.XMLTYPE(XMLSchema "http:
//word.xsd" Element "word")
STORAGE Object-relational TY
PE "word5828_T"
IS_ACTIVE NUMBER
RELEASE_CODE NUMBER
SQL> edit
Wrote file afiedt.buf
1 select count(*)
2 from XML_WORD,
3 table (xmlsequence(extract(XML_CONTENT,'count(/word/noun/sense[1]/collocation')))
4* where ID=9973
SQL> /
from XML_WORD,
ERROR at line 2:
ORA-31013: Invalid XPATH expression

Sure - thanks for the time and thoughts.
I am using the schema you helped me with a bit ago, Re: unique constraint defined in xsd
I have tried to create a stored function that will return the number of maps per username and also one that will return the map elements based on a passed username.
CREATE OR REPLACE FUNCTION COUNTMAPS(userName varchar2)
return number
as numMaps number;
begin
select count(*)
into numMaps
from mapsetxml,
table (xmlsequence(extract(object_value,'/mapset/map')))
where existsNode(object_value, '/mapset[" ' ||userName|| ' "]')=1;
return numMaps;
end;
I get the total number of maps, not the number of maps associated with a particular user.

Similar Messages

  • Counting number of elements

    Suppose you have xml that has repeated nodes, like:
    <foo>
    <bar>some</bar>
    <bar>stuff</bar>
    <bar>here</bar>
    </foo>
    What query would I give to count the number of <bar> elements? Also, is there a query that would concatenate the contents of all of them?
    Thanks.

    This is covered in the standard XDB Demo
    select count(*)
    from purchaseorder,
    table (xmlsequence(extract(object_value,'/PurchaseOrder/LineItems/LineItem'))) l

  • Counting number of elements in an array which aren't empty?

    i tried using this method to count an array which has 100 elements but it doesn't go past the while statement which i cant figure out?
    public static void countCust()
    int cntr = 0;
    int z;
    for (int c = 0; c < 100; c++)
    while (customer[c].indexOf(':') != -1)
    cntr++;
    javax.swing.JOptionPane.showMessageDialog(null, "There are " + cntr + " customers on record");
    }

    Are you getting NullPointerExceptions?
    Are you sure customer[] has been allocated?
    Are you sure each element in the array is non-null?
    BTW, it's traditional to use variables in loops that are closer to their mathematical usage. I mean, for an array index, usually you'd use variables named i or j, unless the indices map to coordinates in space, in which case you'd use x, y, and z.
    If neither of these is applicable, use a variable with a more meaningful name.

  • Count the number of elements in an Arraylist

    My arraylist has these elements inside it.
    [house,tom:, agent,, person,, untidy,jack:, ordered,, tidy,, tiled,roof,tom:, agent,, person,,.....]. The list continues like this.
    How can I count the number of elements after each tom upto before each jack and same for all words after jack and upto before tom? [for example in the first case there are 3 words after tom and there are 4 words after jack.]
    Thanks

    don't collapse your lists together. They represent separate data entities and should be kept separate. Go check your [other thread|http://forums.sun.com/thread.jspa?threadID=5416414&tstart=0].
    Edited by: DeltaGeek on Nov 17, 2009 11:07 AM

  • In OBIEE RPD hierarchy,while defining levels  Number of elements count?

    Whats the importance of NUMBER OF ELEMENTS AT THIS LEVEL (count) while defining the hierarchy level.Does I need to enter the MAXIMUM distinct values of any element in that dimension table.If Yes how will that value gets updated when data in DB changes.Or can I mention depending on level count too like Level 1(1),Level2(2) ...

    use search functionality of the forum
    Re: Estimate Levels

  • Count the number of elements in comma seperated list of values

    Hello Friends,
    I have a string with comma seperated list of values say
    String v = 34343,erere,ererere,sdfsdfsdfs,4454,5454,dsfsdfsfsd,fsdfsdfsdfs,dfdsfsdfsdfs,sdsfdsf,ererdsdsd45454,fsdfsdfs
    Want to count how many elements are existing in this string .
    Thanks/Kumar

    Hi, Kumar,
    REGEXP_COUNT, which Hoek used, is handy, but it only works in Oracle 11. Which version of Oracle are you using?
    In any version of Oracle, you can count the commas by seeing how much the string shrinks when you remove them.
    LENGTH (str) + 1 - LENGTH (REPLACE (str, ',')) Can str have multiple commas in a row? What if there's nothing between consecutive commas, or nothing by whitespace? Can str begin or end with a comma? Can str consist of nothing but commas? Depending on your answers, you may have to change things. You might want
    REGEXP_COUNT ( str
                 , '[^,]+'
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using.
    See the forum FAQ {message:id=9360002}

  • How to get the number of elements in DB

    Could you tell me how to get the number of elements in DB??
    My code to get the number is below, but I think it is not efficient
    DB->cursor(DB, NULL, &cursorp, 0);
    while ((ret = cursorp->c_get(cursorp, &key, &data, DB_NEXT)) == 0)
    count++;
    --------------------------------------------------------------------------------------------------------------

    Hi,
    The most efficient way to get a count from the database is using the DB->stat API (http://docs.oracle.com/cd/E17076_02/html/api_reference/C/dbstat.html)
    The code will be something like:
            DB *dbp;
            DB_BTREE_STAT *statp;
            int ret;
            /* Print out the number of records in the database. */
            if ((ret = dbp->stat(dbp, NULL, &statp, 0)) != 0) {
                    dbp->err(dbp, ret, "DB->stat");
                    goto err1;
            printf("%s: database contains %lu records\n",
                progname, (u_long)statp->bt_ndata);
            free(statp);The code comes from the example included in the distribution at examples/c/ex_btrec.c
    If the database isn't a btree, you should update to the appropriate statistics structure and field.
    It's worth noting that retrieving the count is never a "cheap" operation. The count is not stored in the database - since doing so introduced a single point of contention that creates a bottle neck.
    Regards,
    Alex Gorrod
    Oracle Berkeley DB

  • How to count number of ones in table

    Hello,
     i created one table 16x32 each cell is updating 1 byte of data,how to count number of one in all cell,and is it right way to calculate check sum??
    thank you

    The simplest way is to call GetTableCellRangeValues with VAL_ENTIRE_TABLE as the range, next summing array elements.
    But I don't understand your comment on checksum, so this may not be the more correct method for your actual needs: can you explain what do you mean?
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • Write two functions to find the the number of elements in a linked list?

    I am trying to Write two functions to find the the number of elements in a linked list. One method using recursion and One method using a loop...
    //The linked List class is Represented here.
    public class lp {
    public int first;
    public lp rest;
    public lp(int first1, lp rest1)
    first = first1;
    rest = rest1;
    The program i wrote so far is
    import java.util.*;
    import linklist.lp;
    public class listCount{
    //loop function
    public static void show_list(lp list)
    int counter = 0;
    while(list != null)
    list = list.rest;
    counter++;
    System.out.println ("length computed with a loop:" + counter);
    //recursive function
    public static int recursive_count(lp list)
    if (list.first == null)
    return 0;
    else
    return recursive_count(list.rest) + 1;
    //main method
    public static void main (String args[])
    lp list1 = new lp(1, new lp(2, new lp(3, null)));
    show_list(list1);
    System.out.println("length computed with a recursion:" +
    recursive_count(list1));
    at the if (list.first == null) line i get the error " incomparable types:
    int and <nulltype>" I know this is a beginners error but please
    help...What should I do?

    byte, char, short, int, long, float, double, and boolean are primitives, not objects. They have no members, you cannot call methods on them, and they cannot be set to or compared with null.

  • Counting number of lines in a text/csv file using xquery/xslt.

    Hi,
    I have a CSV file, I need to count the total number of lines in that file. This I have to use in OSB. My requirement is I have to count total no of lines in the $body file (CSV/flat file) and subtract header and footer lines from it.
    EX:
    header,1, @total_no_of_detal@
    detail,1
    detail,2
    detail,3
    detail,n
    footer, 1
    If suppose i have 10 detail lines, and I am getting body of the file as shown above,
    then in the final file, I have to change the body of the file as:
    header,1, *10*
    detail,1
    detail,2
    detail,3
    detail,n
    footer, 1
    Please advice how to do this in OSB.
    Edited by: user12679330 on Aug 2, 2011 2:34 AM

    I would suggest you to use MFL to convert the file into XML when you read it and then you can count the detail elements within the XML and update the values in Header element before writing the file again in flat file format again using MFL.
    You can read the documentation of Format Builder utility which is used to define MFL here:
    http://download.oracle.com/docs/cd/E21764_01/doc.1111/e15866/part_fb.htm
    Alternatively, another approach is the read the whole flat file as a text string and then doing needed manipulations to get what you need. If you want to do it like this then you will need to consider following things:
    1. Is the file in DOS format or Unix format? (To know the End of line character in use)
    2. Does the file contain an end of line at the end of file? (whether there is an end of line char at the end of data of footer record)
    Once you know above, you can try an xquery like following:
    let $intermediateXML :=
    <Root>
    for $a in (tokenize($in, 'EOL'))
    return
    if (string-length($a) > 0)
    then
    <record>{$a}</record>
    else ()
    </Root>
    let $count := count($intermediateXML/record)
    let $outXML :=
    <OutRoot>
    for $i in 1 to $count
    return
    if (data($i) = 1)
    then
    <Record>{concat($out, $intermediateXML/record[$i]/text(), ',Count=',($count)-2)}</Record>
    else
    <Record>{concat($out, $intermediateXML/record[$i]/text())}</Record>
    </OutRoot>
    return op:concatenate($outXML/Record/text(), 'EOL')In Above XQuery, replace EOL with the end of line character which for unix wound be "&#xA ;" (remove quotes and space between the A and ; ) and for DOS would be "&#xD ;&#xA ;" (remove quotes and space between the A and ; and D ; )

  • Total number of elements in an array

    Hello, 
    I am trying to count the total number of elements in an array. 
    I have a simulate signal VI, that simulates a square pulse, this is being written into an excel file using the write to measurement VI, all for a given period of time. 
    I want to further chop a window of the signal depending on different paramenters (a trigger, which I intend to incorperate later, for now I am working of learning how to chop the data)
    In order to chop the data I need to know the array size, I use the array size funtion, I right click on the appeneded array in the front pannel and click show last element (array size -1) it doesnt match with the number of rows in the excel file written by the write to measurement VI, in fact it macthes with the "number of samples" I selected in the simulate signal VI. 
    Am I doing something wrong? 
    Why is there a miss match??
    I have attached my VI, Please help
    Thank You
    SP
    Attachments:
    FlashERGTrialVI 150218.vi ‏93 KB

    Hello RavensFan
    Thank you for the reply, I did incorperate the changes, but the same number is displayed in the indicator.  I've attahced my VI
    SP
    Attachments:
    FlashERGTrialVI 150218.vi ‏106 KB

  • How Do I Print the Number of Elements in An Array

    How do I print: "There are ____ number of elements in the array?"

    If you have a String holding a sentence, and if you split on non-empty sequences of whitespace (if the string has newlines in it, you'd probably need to pass the argument that makes \s match newlines, and for that you would probably need to use java.util.regex.Pattern -- see the docs and try some tests), when you'd get an array of Strings that were the non-whitespace parts of the original String. That makes for a reasonably good definition of the words in the sentence, although you could arguably get into some gray areas (does "isn't" count as one or two words? Does a sequence of numbers or punctuation qualify as a word?). In that case, counting the number of elements in the resulting array of String. using .length, would be a reasonable way to get the number of words in that sentence, yes.
    But rather than asking for confirmation on forums, why don't run some tests?
    import java.io.*;
    public class TestWordCount {
      public static void main(String[] argv) {
        try {
          BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
          String line;
          while((line = in.readLine()) != null) {
            int count = // your code here, to count the words
            System.out.println("I see " + count + " words.");
        } catch (IOException e) {
          e.printStackTrace();
    }Put your word-counting code in there, then run it from the command line. Type in a sentence. See how many words it thinks it found. Does it match with your expectation, or the examples given (hopefully) with your homework assignment?

  • Number of Elements - What is it?

    Hi,
    I am trying to ramp up on OBIEE, and I am going through the OBE tutorials.
    In creating levels in the dimensional hierarchies, the tutorial has you specify a field called "Number of elements at this level". It doesn't really explain what it's used for, or give guidelines on what to enter for this field. Could someone please explain it a little further? I would really appreciate it!
    Thanks,
    Kevin

    From what I know , it is number of distinct values at that level in physical table.
    E.g. at region level it is
    select count distinct region from physical table.
    Not sure how this information is exactly used by BI server. The number does not have to exact but the ratio has to be approximate.

  • Number of elements in a geometry

    Hi All,
    I am wondering if there is any way to enquire on a geometry to determine how many elements it contains. Eg: a polygon with an outer boundary and two inner holes would have three elements. I am guessing that the sdo_elem_info_array would need to be interrogated, but does anyone know of a neat method to do that?
    many thanks for any suggestions!
    Kay

    Hi Andreas,
    Thankyou very much for your reply - you have set me on the right track.
    I am now using the following function to obtain the number of entries in the sdo_elem_info varray:
    create or replace function sdo_elemcount(gt mdsys.sdo_geometry)
    return number
    is begin
    return (gt.sdo_elem_info.count());
    end sdo_elemcount;
    then running as follows to get the number of elements:
    select sdo_elemcount(geom)/3 from table_name where objectid = x;
    dividing by 3 gives me the number of distinct elements in the geometry.
    Thanks for your help Andreas!
    Kay

  • Number of elements in XML file

    Hi,
    I have an xml file as follows
    <xml>
    <head>
    <h1>xxxx</h1>
    </head>
    <line>
    <name>ravi</name>
    <dept>Oracle</dept>
    </line>
    <line>     
    <name>Kamal</name>
    <dept>Java</dept>
    </line>
    <line>
    <name>Ajay</name>
    <dept>Linux</dept>
    </line>
    </xml>
    I need to insert the above xml file into a table.
    For that i have used the following query.
    insert into dest_table
    SELECT     EXTRACTVALUE (t2.xml_doc, '/xml/head/h1') head,
    EXTRACTVALUE (t2.xml_doc, '/xml/line['||level||']/name') name,
    EXTRACTVALUE (t2.xml_doc, '/xml/line['||level||']/dept')dept
         FROM xml_table t2
         CONNECT BY LEVEL <= n
    Here n in CONNECT BY clause is the number "<line>" elements (3 in the above example).
    If i know the number of <LINE> elements,then i can easily select and insert the xml data.
    BUT How to know the number of particular elements(<line> in above xml) in the above xml using oracle xml oracle.
    any idea psl.
    cheers
    RRK

    select count(1) from table(
        xmlsequence(
            extract(
                XMLType('&lt;root&gt;&lt;a&gt;b&lt;/a&gt;&lt;a&gt;c&lt;/a&gt;&lt;a&gt;d&lt;/a&gt;&lt;x&gt;z&lt;/x&gt;&lt;/root&gt;'),
                '/root/a'
    )

Maybe you are looking for

  • Problem in Character Mode Report (Urgent)

    Dear All i m designing a character mode report and when i preview it ,,, it will display different report font which is big in size and width so it is not fit in the designed columns can any one help me ,, y this problem is exist though i m using Dot

  • Message size limit

    Hi all, I have a question regarding the message size for the mapping: What is the size limit for messages when using the XSLT mapping methods? What are the maximum message sizes (if any) for the other methods like ABAP mapping, Graphical mapping, JAV

  • Regarding RFC for SD n MM related to RFID

    hi all Will anybody give RFC for delivry of goods in Retail m using RFID technology Regards Abhijeet

  • Trying to include a calendar in PDF.

    How do I include a calendar into my PDF doc? Downloaded tool bar from Formrouter but can't see it in adobe

  • HP Printer Assistant Software Missing Scan Option on DeskJet 2542

    I have installed the Printer Assistant Software on both an HP Desktop and a Lenovo Laptop.  I have two HP DeskJet 2542 Printers in two different physical loactions that I connect to with the Laptop.  On the Desktop computer the install of the softwar