PL/SQL - counting values' occurences in a collection - how to optimize?

Hi all,
I'm new here and working currently on my PhD thesis, using Oracle (XE) to do some data manipulation stuff.
Following is defined:
TYPE stat_col_type IS TABLE OF INTEGER;
rows_lens stat_col_type;
Using MULTISET UNION operations, I get the final rows_lens as a set of values, e.g. {1,2,3,1,1,2,2,2,3,3,3,3,3,3,3,1,1,2,1,1,4,5,6,2,2,2,3,3}.
What I need is to count the occurences of the unique values :
value of 1 : 7 occurences
value of 2 : 8 occurences
value of 3 : 10 occurences
value of 4 : 1 occurence
value of 5 : 1 occurence
value of 6 : 1 occurence
Ideally, the result should be a separate collection where the values become indexes (there are numbers, natural, unique and countable) and the number of occurences - their values :
output_col( value ) := number-of-occurences ;
Of course, I could just go through all the elements incrementing the counters in the output collection, but surely there must be a most efficient way - probably using POWERMULTISET or some kind of SUBSETS. As haven't been using /developing in/ Oracle for a longer period... it's better to ask :)
Thanks in advance for your suggestions.
Regards,
Bart
Edited by: user3698166 on 2010-01-16 13:44

What I need is to count the occurences of the unique values :
Following is defined:Why don't you define in PLSQL and not in SQL?
It would be so much easier:
SQL> create type stat_col_type as table of integer
Type created.
SQL> select column_value, count (column_value) cnt
  from table (
          stat_col_type (1,
                          2,
                          3,
                          1,
                          1,
                          2,
                          2,
                          2,
                          3,
                          3,
                          3,
                          3,
                          3,
                          3,
                          3,
                          1,
                          1,
                          2,
                          1,
                          1,
                          4,
                          5,
                          6,
                          2,
                          2,
                          2,
                          3,
                          3
group by column_value
order by column_value
COLUMN_VALUE        CNT
           1          7
           2          8
           3         10
           4          1
           5          1
           6          1
6 rows selected.
SQL> drop type stat_col_type
Type dropped.

Similar Messages

  • Connect by Level using count value from record collection

    Hello:
    PROBLEM:
    ) y,(select rownum MonthNo from dual connect by level <= Cnt)
    Causes ORA-00904 Invalid identifier. Why can’t I use “Cnt” from my main query as using a constant works?
    The count value is determined for each date range in How can I return the records I need?
    Thanks, Sidney
    BACKGROUND:
    I need to be able to display a list of tax returns to my users and the status of those returns. Physical returns do not exist so it is necessary to create the data records dynamically using appropriate selects. This is not difficult and I thought I could then just use a connect by level to give me the date information so I could calculate and display the individual returns. However oracle is giving me an ORA-00904 when I try to send the “Cnt” value to connect by level. Everything works fine when I provide a constant instead of “CNT”. The “CNT” value is determined by a complex process that computes the start and stop dates for multiple return types, etc. as well as the number of periods and filing frequency. The data has to be dynamically generated using a master record which then yields the coding history from which my basic record collection is selected. Here is the result of that process:
    TaxpayerNo,TaxClass,TaxCode,FilingFequency,StartDate,StopDate,Cnt,Frequency
    10 S 1 M 6/1/2007 11/30/2008 18 12
    10 S 2 M 11/30/2008 9/30/2009 10 12
    10 S 2 Q 11/30/2010 8/18/2011 3 4
    10 L 8 A 6/1/2007 9/30/2009 3 1
    10 L 8 A 11/30/2010 8/18/2011 1 1
    From this data, I need a record for each individual month,quarter,etc. ie:
    10 S 1 M 6/1/2007 11/30/2008 18 12 6/1/2007
    10 S 1 M 6/1/2007 11/30/2008 18 12 7/1/2007
    10 S 1 M 6/1/2007 11/30/2008 18 12 8/1/2007
    10 S 1 M 6/1/2007 11/30/2008 18 12 9/1/2007
    10 S 2 M 11/30/2008 9/30/2009 10 12 11/30/2008
    10 S 2 M 11/30/2008 9/30/2009 10 12 12/30/2008
    etc.
    DOES NOT WORK
    select y.*,MonthNo,Add_Months(StartDate,MonthNo*Frequency) from (
    select x.*,
    (case when FilingFrequency = 'M' then Ceil(Months_Between(StopDate,StartDate))
    when FilingFrequency = 'Q' then Ceil(Months_Between(StopDate,StartDate)/3)
    when FilingFrequency = 'A' then Ceil(Months_Between(StopDate,StartDate)/12)
    else 0
    end) Cnt,
    (case when FilingFrequency = 'M' then 1
    when FilingFrequency = 'Q' then 3
    when FilingFrequency = 'A' then 12
    end) Frequency
    from (
    ... complex code to calculate the values of the start and stop dates needed above...
    ) x
    ) y,(select rownum MonthNo from dual connect by level <= Cnt)
    ERROR MESSAGE
    This returns ORA-00904: "CNT": Invalid Identifier. I don't get an error if I use a constant:
    WORKS USING A CONSTANT BUT MUST HAVE THE ACTUAL CNT VALUE
    ... Same code to generate data ...
    ) y,(select rownum MonthNo from dual connect by level <= 3)
    How can I get this to work using the "CNT" value instead of a constant?

    A technique like this should fix your problem.
    TUBBY_TUBBZ?with data (col1, cnt) as
      2  (
      3    select 1, 3 from dual
      4      union all
      5    select 2, 2 from dual
      6  )
      7  select
      8    d.col1,
      9    t.column_value
    10  from
    11    data  d,
    12    table(cast(multiset(select level from dual connect by level <= d.cnt) as sys.OdciNumberList)) t;
                  COL1       COLUMN_VALUE
                     1                  1
                     1                  2
                     1                  3
                     2                  1
                     2                  2
    5 rows selected.
    Elapsed: 00:00:00.00
    TUBBY_TUBBZ?As opposed to what you have now, which is basically this
    TUBBY_TUBBZ?with data (col1, cnt) as
      2  (
      3    select 1, 3 from dual
      4      union all
      5    select 2, 2 from dual
      6  )
      7  select
      8    d.col1,
      9    level
    10  from
    11    data  d
    12  connect by level <= d.cnt;
                  COL1              LEVEL
                     1                  1
                     1                  2
                     1                  3
                     2                  2
                     1                  3
                     2                  1
                     1                  2
                     1                  3
                     2                  2
                     1                  3
    10 rows selected.
    Elapsed: 00:00:00.00
    TUBBY_TUBBZ?

  • How to get counter value from Historian

    Hi Experts,
    We have got a scenario to keep the number (counter) to see how many time a value of tag have been changed.
    For Example:
    If the values change from 1 to 0 and  0 to 1 for 25 times in a minute. We would like to get this number (25) from Historian (Wonderware).
    Currently we are not using any Pco to fetch the value from Hisotrian since we are able to fetch the tag values from Historian database through SQLConnection.
    I would like to know if we introduce Pco, will that help us to get this counter value.
    We are working on MII 15.0 version.
    Any help of this very much appreciated.
    Thanks
    Shaji

    Hi Shaji,
    PCo OPC DA does not support  PCoQuery TagAggregateMode as it only has access to Current Values of OPC Tags, because OPC DA only provides Current Value access.
    I know it is possible to execute SQL queries against the Wonderware Historian to retrieve counts aggregates, but don't have the details handy. Recommend that you deploy the InSQLPCo Data Server in MII and try using the PCoQuery TagAggregateMode method to retrieve the Counts aggregate first.
    Regards, Steve

  • How to count  the length of a  collection in JSTL?

    Hi ,Everyone.
    I want to count the length of a collection in JSTL.
    For example:
    <c:out value="${length(ownerList)}" />
    the program compile wrong. Is length function supported in JSTL?
    Thanks in advance!

    Use:
    <c:out value="${fn:length(ownerList)}"/>You'll have to include the functions taglib to use the function:
    <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>

  • Idoc to file scenario which involves accessing a persistant counter value

    Hi,
    Presently Iam dealing with an idoc to file scenario in which I need to map the idoc info and also a persistant counter value to a flat file. So in how many ways can we maintain a persistant counter value(either by variable/file/database)? Please can any one help me in overcoming this scenario by providing any implemented example.

    Hi,
    Please see the following links , you can use database is best.
    /people/prasad.illapani/blog/2006/10/25/how-to-check-jdbc-sql-query-syntax-and-verify-the-query-results-inside-a-user-defined-function-of-the-lookup-api
    /people/michal.krawczyk2/blog/2005/09/15/xi-rfc-mapping-lookups-from-bc-to-xi
    /people/morten.wittrock/blog/2006/03/30/wrapping-your-mapping-lookup-api-code-in-easy-to-use-java-classes
    /people/alessandro.guarneri/blog/2006/03/27/sap-xi-lookup-api-the-killer
    /people/alexander.schuchman/blog/2005/09/29/ipc-customization--add-additional-subtotals-and-include-rebate-conditions
    Regards
    Chilla..

  • PL/SQL NUMERIC VALUE ERROR

    Hi ,
    We have following code and sending the data through attachnmet its giving the pl/sql numeric value error.
    Please correct me.
    __Code Details:::__
    CREATE OR REPLACE PROCEDURE APPS.print_reports
    IS
    wfile_handle UTL_FILE.file_type;
    lv_file VARCHAR2 (100);
    lv_date VARCHAR2 (20);
    mail_conn UTL_SMTP.connection;
    lv_rep_headers VARCHAR2 (32000);
    p_o_srv_result xxcss_prf_report_pkg.ref_cur_srv_prog;
    lv_str_type XXCSS_PRF_STRING;
    lv_line VARCHAR2 (32767);
    lv_send_to VARCHAR2 (200);
    lv_host_name VARCHAR2 (200) := 'outbound.cisco.com';
    l_vtab CHAR := CHR (9);
    lv_from VARCHAR2 (200) := '[email protected]';
    lv_att_file_name VARCHAR2 (200);
    lv_path VARCHAR2 (200);
    p_request_type VARCHAR2 (1) := 'E';
    p_request_id NUMBER;
    errbuf VARCHAR2 (2000);
    retcode NUMBER;
    crlf VARCHAR2 (2) := CHR (13) || CHR (10);
    lv_line_data Clob;
    lv_clob clob;
    BEGIN
    BEGIN
    SELECT VALUE
    INTO lv_path
    FROM v$parameter
    WHERE NAME = 'utl_file_dir';
    EXCEPTION
    WHEN OTHERS
    THEN
    lv_path := '\tmp';
    END;
    lv_rep_headers :=
    'REGION'
    || CHR (9)
    || 'COUNTRY'
    || CHR (9)
    || 'CUSTOMER NAME'
    || CHR (9)
    || 'ERP CUSTOMER NUMBER'
    || CHR (9)
    || 'PROFILE ID'
    || CHR (9);
    FOR i IN ( SELECT DISTINCT srv_program_id srv_prgm
    FROM xxcss_prf_cust_srv_programs
    ORDER BY srv_program_id ASC)
    LOOP
    lv_rep_headers := lv_rep_headers ||i.srv_prgm || CHR (9);
    END LOOP;
    lv_rep_headers := lv_rep_headers || CHR (13);
    BEGIN
    XXCSS_PRF_REPORT_PKG.offline_daemon (p_request_id,
    p_request_type,
    p_o_srv_result,
    errbuf,
    retcode);
    EXCEPTION
    WHEN OTHERS
    THEN
    DBMS_OUTPUT.PUT_LINE ('Error in Offline');
    END;
    lv_att_file_name := 'Eligibility_reports'||p_request_id||'.xls';
    -- DBMS_OUTPUT.PUT_LINE (lv_rep_headers);
    wfile_handle := UTL_FILE.fopen (lv_path, lv_att_file_name, 'W');
    UTL_FILE.put_line (wfile_handle, lv_rep_headers);
    BEGIN
    LOOP
    FETCH p_o_srv_result INTO lv_str_type;
    EXIT WHEN p_o_srv_result%NOTFOUND;
    lv_line := NULL;
    FOR i IN 1 .. lv_str_type.COUNT
    LOOP
    lv_line := lv_line || lv_str_type (i) || CHR (9);
    END LOOP;
    lv_line := lv_line || CHR (13);
    UTL_FILE.put_line (wfile_handle, lv_line);
    END LOOP;
    lv_str_type.DELETE;
    END;
    UTL_FILE.fclose (wfile_handle);
    BEGIN
    wfile_handle := UTL_FILE.FOPEN (lv_path, lv_att_file_name, 'R');
    -- DBMS_OUTPUT.PUT_LINE ('inside file');
    LOOP
    UTL_FILE.GET_LINE (wfile_handle, lv_line_data,32767);
    -- DBMS_OUTPUT.PUT_LINE (lv_line_data);
    lv_clob := lv_clob || lv_line_data;
    END LOOP;
    UTL_FILE.FCLOSE (wfile_handle);
    EXCEPTION
    WHEN OTHERS
    THEN
    errbuf := sqlerrm;
    UTL_FILE.FCLOSE (wfile_handle); -- close file
    DBMS_OUTPUT.PUT_LINE ('Exception'||errbuf);
    NULL;
    END;
    DBMS_OUTPUT.PUT_LINE ('afterdata');
    --DBMS_OUTPUT.PUT_LINE (lv_line_data);
    SELECT email_id
    INTO lv_send_to
    FROM xxcss_prf_offline_report_tb
    WHERE request_id = p_request_id AND report_type = p_request_type;
    mail_conn := UTL_SMTP.open_connection (lv_host_name, 25);
    UTL_SMTP.Helo (mail_conn, lv_host_name);
    UTL_SMTP.Mail (mail_conn, 'sangrdas');
    UTL_SMTP.Rcpt (mail_conn, lv_send_to);
    UTL_SMTP.OPEN_Data(mail_conn) ;
    DBMS_OUTPUT.PUT_LINE ('Sending Data');
    UTL_SMTP.write_Data (
    Mail_Conn,
    'Date: '
    || TO_CHAR (SYSDATE, 'Dy, DD Mon YYYY hh24:mi:ss')
    || crlf
    || 'From: '
    || lv_from
    || crlf
    || 'Subject: ELIGIILITY Report_'
    || p_request_id
    || crlf
    || 'To: '
    || lv_send_to
    || crlf
    || 'MIME-Version: 1.0'
    || crlf
    || -- Use MIME mail standard
    'Content-Type: multipart/mixed;'
    || crlf
    || ' boundary="-----SECBOUND"'
    || crlf
    || '-------SECBOUND'
    || crlf
    || 'Content-Type: text/plain;'
    || crlf
    || 'Content-Transfer_Encoding: 7bit'
    || crlf
    || 'some message text'
    || crlf
    || -- Message body
    'more message text'
    || crlf
    || '-------SECBOUND'
    || crlf
    || 'Content-Type: text/plain;'
    || crlf
    || ' name="'|| lv_att_file_name||'"'
    || crlf
    || 'Content-Transfer_Encoding: 8bit'
    || crlf
    || 'Content-Disposition: attachment;'
    || crlf
    || ' filename="'
    || lv_att_file_name
    || '"'
    ||crlf
    ||crlf
    ||lv_clob
    || crlf
    ||crlf
    ||crlf
    || '-------SECBOUND');
    UTL_SMTP.CLOSE_Data(mail_conn) ;
    UTL_SMTP.quit (mail_conn);
    DBMS_OUTPUT.PUT_LINE ('After Mail');
    EXCEPTION
    WHEN OTHERS THEN
    errbuf := sqlerrm;
    DBMS_OUTPUT.PUT_LINE ('ERROR Sending Data'||errbuf);
    ROLLBACK;
    END;
    /

    Yet again, opening a new thread for an existing issue...
    Need help in UTL file
    Same old, same old...
    need a report code
    need to create the header dynamically for a report
    Would have thought you'd get the idea of posting on the forums by now.

  • Jslt +sql count

    Hi,
    i would be thanksfull fi anyone would tell me, how to get the value from the count sql-statement using jstl..
    the tags should look sth like this:
    <sql:query var="getUser" >
    SELECT COUNT(Row) FROM table
    </sql:query>
    <c:set var="count" value="${getUser}" scope="page" />
    but sth is wrong. for any suggestion thanks!

    ive solve this in that way..
    <sql:query var="getUser" >
    SELECT COUNT(Row) AS cnt FROM table
    </sql:query>
    <c:forEach var="Temp" begin="0" end="1" items="${getUser.rows}">
    <c:set var="users" value="${Temp.cnt}" scope="session" />
    </c:forEach>
    but if there is any way to set the variable users in some way with using only one tag?

  • SQL JSTL  displat y the count ..  cant figure out how please help......

    Hi all,
    I facing a problem in displaying the count total.. My situation is that I run below query ..
    <sql:query var="jobs" dataSource="jdbc/test">
              SELECT COUNT(*) FROM applications where employerid = '12345610' GROUP BY job_id
              </sql:query>
              <c:forEach var="row" items="${jobs.rows}">
              <li> Count <span id="count"> [<c:out value="${row.??? )}]</span></li>
              </c:forEach>
    {code}
    when I run the same sql in sql prompt it gives me 10 groups with relevant counts.
    but I cant figure out how to do the same using JSTL sql.  in simple terms I want to display the count of each logical group ?  I have tried all I can wit my little knowledge on the subject..
    I will appreciate if someone could help me out please..
    Million Thanks in advance.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    I found the answer my self... It took me just a 4 sleep to find the answer ,,, a break and a coup of coffee did the job
    I chanced the code as below
    SELECT COUNT(*) as cnt FROM applications where employerid = '12345610' GROUP BY job_id
              </sql:query>
              <c:forEach var="row" items="${jobs.rows}">
              <li><a href="/test/servlet/Controller?param=Security">Security </a><span id="count">[<c:out value="${row.cnt }"/>]</span></li>

  • How to get counter values from pci 6221 card?

    Hii
     I am using PCI 6221 card .. In that i am using the ctr o .. In my application i am using Linear encoder to measure the Lift movement.. so from software how to access the counter values i.e how much mm it moves... 

    Measure Angular Position.vi in the LabVIEW examples will be a good starting point. Adapt it to Linear Encoder by clicking on the selector below DAQmx Create Channel.vi.
    You can also create a corresponding DAQmx Global Channel (or task) in MAX and then use it in your code.
    Feel free to post back if you need further help.
    Message Edité par JB le 10-31-2008 02:15 PM

  • Counter value jumps on occasion (PXI 6255)

    I am using a PXI 8108 controller (Windows) with a PXI 6255 AI card. A pulse generator (1 KHz) is incrementing the hardware counter of that AI card in order to have an external reference clock, i. e. having a timestamp for each AI sample value.
    I am reading 1000 AI values from several channels  (together with 1000 counter values) via DAQmx blocks with a higher frequency than the external clock's 1 KHz (e.g. AI Rate 5 KHz-> reading every counter value approx. 5 times). Every now an then I am losing counter values, e. g. counter value 6789 is followed by 6823.
    Shouldn't be the PXI card's counter buffer independant of Window's CPU load? Getting 1000 values from the card buffer, the jumps are even located in the middle of the 1000 values. Maybe there's a problem with atomicity while reading from the buffer, so that I get 500 values from the buffer, (pause), and 500 more values from a later point in time. Is this possible?
    I am sure, I can not blame the digital pulse generator (from Hameg Instruments) for dropping pulses.
    Attachments:
    counter-daq.png ‏20 KB

    Hello,
    If the first scan only places 4 samples in the AI FIFO (2 less than the number of channels requested), then I would expect this loop to run forever in aiex1.cpp (I added some debugging prints to make it easier to see the channels that should be getting returned).
           while ( m < numberOfChannels )
            if(!board->AI_Status_1.readAI_FIFO_Empty_St())
                value = board->AI_FIFO_Data.readRegister ();
                aiPolynomialScaler (&value, &scaled, &scale);
                printf ("Channel %d: %e,\n", m, scaled);
                m++;
        printf("\tEnd of Sample %d\n", n);
    How is the example able to proceed past this loop?
    I have checked the code for FIFO flushes and resets between aiStartOnDemand (board); and when the FIFO gets read.  I have also run the example with 6 channels, this time on Windows.
    To proceed we would need these items:
    1) We would need the exact output (with my added debug prints).
    2) A complete dump of all registers accessed during the example.
    Steven T.

  • How to get seeburger work bench counter value

    hi all,
    i want to get the current counter value in the seeburger workbech counter.
    i used the following function suggested in one of the threads in forum, but its giving the below error
    func used:
    try {
    VariableBean be=VariableFactory.getVariableInstance("");
    return be.getStringVariable(variableName);
    } catch (Exception e) {
    throw new RuntimeException(e);
    error:
    RuntimeException in Message-Mapping transformation: Exception:[java.lang.RuntimeException: java.lang.RuntimeException: VariableBeanServlet: Could not call getVariable() method of the Servlet. Cause=java.lang.ClassCastException]
    i guess this above function is to get variable value and not counter value. can any body give me code to get counter value.
    Thanks a lot in addvance
    Regards,
    Rashmi
    Edited by: Rashmi H S on Aug 12, 2009 2:30 PM

    use getCounter
       //write your code here
    try {
    CounterBean be=CounterFactory.getCounterInstance();
    return ""be.getCounter("counterName_"b"_"a );
    } catch (Exception e) { 
        throw new RuntimeException(e.getMessage()); 
    will return the same counter what you have ,I also had same scenario what you are facing recently
    HTH
    Rajesh
    Edited by: Rajesh on Aug 13, 2009 7:49 PM

  • XI Adapter Illegal count value 0

    Hi all,
    When configuring the PI Adapter to connect for outbound messaging from MDM, we are receiving the following error:
    Illegal Count Value 0
    This error is in the Component Monitoring.
    Looking in the logs, this seems to be occuring because of the error here:
    Catching java.lang.Exception: Illegal count value 0.
    at com.sap.mdm.xiadapter.util.MdmUtil.getPortProperties(MdmUtil.java:98)
    at com.sap.mdm.xiadapter.AbstractMdmAdapter.start(AbstractMdmAdapter.java:214)
    at com.sap.mdm.xiadapter.MdmSender.start(MdmSender.java:46)
    at com.sap.mdm.xiadapter.jca.XIConfiguration.channelAdded(XIConfiguration.java:160)
    at com.sap.aii.af.service.administration.impl.AdminManagerImpl.notifyChannelActivationStateChanged(AdminManagerImpl.java:796)
    at com.sap.aii.af.service.administration.impl.cluster.ClusterManager.eventReceivedSync(ClusterManager.java:426)
    at com.sap.aii.af.service.event.impl.worker.sync.SyncLocalWorker.work(SyncLocalWorker.java:52)
    at com.sap.aii.af.service.event.impl.worker.sync.AbstractSyncWorker.startWork(AbstractSyncWorker.java:40)
    at com.sap.aii.af.service.event.impl.EventManagerImpl.sendEventAndWaitForAnswer(EventManagerImpl.java:484)
    Could anyone provide any advice on this?  The error occurs even if the Port is deliberately configured incorrectly, but only occurs when the Remote System is correctly configured.  Changing the user seemed to make no difference.
    We are using 7.1 SP05
    Thanks in advance,
    David
    Edited by: David Apthorpe on Jul 21, 2010 3:54 PM

    Hi David,
    The error "Configuration Error:illegel count 0" will be fixed MDM 7.1 SP05 Patch06 (bulid 7.1.05.87) which is planned to be released by beginning CW 32 2010.
    This issue only  occured for only Prior to created Communcation Channel SPO5.
    If you create Communcation Channel After Upgarde SP05 ,The messages successfully processed t
    o MDM server(Ready folder).
    Regards,
    Ramesh

  • How to count a occurence of a string in file

    import java.util.*;
    import java.io.*;
    class Count
    public static void main(String args[ ] )throws Exception
         FileReader fr=new FileReader("d:\\compfetch\\clean\\first.txt");
         BufferedReader br=new BufferedReader(fr);
         StringBuffer sb=new StringBuffer();
         while((s=br.readLine())!=null)
              sb.append(s);
         s=sb.toString();
    Vector v= new Vector();
         v.addElement("job");
         v.addElement("jobs");
         v.addElement("career");
         v.addElement("careers");
         v.addElement("vacancy");
         v.addElement("vacancies");
         v.addElement("opportunity");
         v.addElement("openings");
         v.addElement("posting");
         v.addElement("postings");
         v.addElement("opportunities");
         v.addElement("placement");
         v.addElement("placements");
         v.addElement("job");
         v.addElement("job");
         Enumeration vEnum=v.elements();
         while(vEnum.hasMoreElements())
              System.out.println(vEnum.nextElement());
    I need to count the occurence of each string given in the vector from the text file.I have the file and the vector.How do i compare the vector and textfile ,so that i can count the occurence of eachString in the vector with the text file.The text file may contain any of the words given in the vector.If found ,a count shld be made for each string .
    regards,
    koel

    Try this code:
    import java.util.*;
    import java.io.*;
    class Count
    public static void main(String args[ ] )throws Exception
         FileReader     fr = new FileReader("c.c");
         BufferedReader br = new BufferedReader(fr);
         StringBuffer   sb = new StringBuffer();
         String         s;
         while((s=br.readLine())!=null)
              sb.append(s);
         s=sb.toString();
         Vector v= new Vector();
         v.addElement("job");
         v.addElement("jobs");
         v.addElement("career");
         v.addElement("careers");
         v.addElement("vacancy");
         v.addElement("vacancies");
         v.addElement("opportunity");
         v.addElement("openings");
         v.addElement("posting");
         v.addElement("postings");
         v.addElement("opportunities");
         v.addElement("placement");
         v.addElement("placements");
         Enumeration vEnum=v.elements();
         while(vEnum.hasMoreElements())
              String l = (String)vEnum.nextElement();
              int    a = 0;
              int    p = s.indexOf(l,a);
              int    c = 0;
              while (p != -1)
                   c = c + 1;
                   a = a + l.length() + p;
                   p = s.indexOf(l,a);
              System.out.println(l+"  "+c);
    }

  • Perform SQL COUNT from AS3

    Hi there all,
    Just working away as usual and I've encountered a problem with a flash app I'm making..
    I can save and load variables from flash to the mySQL database, but when I load up the results one after the other I eventually run out of results to display, which throws an error !!
    Is there a way I can perform an SQL COUNT from flash to determine the amount of results I have in the database and loop the viewer back to the first result ??
    Many Thanks in advance for any help

    This is how I am parsing and requesting the information.. I know it's in there somewhere I just can't get the variables, do I need to add them ? It's not making much sense to me at the moment, I'm sorry !! I need to add the variables to the request somehow.. so I can receive the info, no ?
    var tab = "SQLtab";
    var filesend = "path to php file";
    var modesend = "post";
    function variableTransaction(fichier, modesend, tab, var1, var2) {
         var URLload = new URLLoader();
         var URLrequest = new URLRequest(fichier);
         var variables:URLVariables = new URLVariables();
         variables.tab = tab;
         variables.var1 = var1;
         variables.var2 = var2;
         if (modesend == "post") {
              URLrequest.method = URLRequestMethod.POST;
         } else if ( modesend == "get") {
              URLrequest.method = URLRequestMethod.GET;
         if (var1 == false && var2 == false) {
              URLload.dataFormat = URLLoaderDataFormat.VARIABLES;
              URLrequest.data = variables;
              URLload.load(URLrequest);
              URLload.addEventListener(Event.COMPLETE, loadComplete, false, 0, true);
         } else {
              URLrequest.data = variables;
              URLload.load(URLrequest);
              var receiveObject = variableTransaction(filesend, modesend, tab, false, false);

  • DB adapter retry count value

    Hi gurus,
    I am using a db adapter for polling options. The option used is 'Delete the row(s) that were read' .
    Here the retry count by default is set to unlimited. Is this the recommended one? In normal db adapter options i see the retry count as '4'
    the property value seen in composite.xml is shown below
    <property name="jca.retry.count" type="xs:int" many="false" override="may">2147483647</property>
    Will this lead to any performance issues? Or what could be the correct retry count value?
    Please let us know.

    Hi,
    We have used the polling options using Logical delete vastly in our project and never faced any performance issues with respect to this property value being set to 'unlimited'.
    I believe there should not be any performance issues with respect to the 'Delete the row(s) that were read' option as well.
    According Oracle documentation:
    In the Auto-Retries section, specify the value for auto-retry incase of time out. In case of a connection related fault, the Invoke activity can be automatically retried a limited number of times. You can specify the following values in the fields in this section:
    To retry indefinitely, type unlimited in the Attempts field.
    Interval is the delay between retries.
    Backoff Factor: x allows you to wait for increasing periods of time between retries. 9 attempts with a starting interval of 1 and a back off of 2 leads to retries after 1, 2, 4, 8, 16, 32, 64, 128, and 256 (28) seconds.
    Thanks,
    Deepak.

Maybe you are looking for