Getting count from ldapseaarch results

Hi,
I am using Netscape Directory Server 4.16.
I am using ldapsearch command to search for specific attributes. When I execute ldapsearch I am getting the results properly.
I would like to know how to get the result count instead of results. At the end of the search results i get a message # no. of matches.
I want this number directly. Is it possible with ldapsearch? Did any one implement this type of functionality? If any one did this before, please give me the code or give me the directions how to do this.
Thanks in advance,
Murthy

Hi,
I did not understand the
dn|grep \^ dn
what is this dn? I tried with this, but I did not get any result.
I used the follwoing command.
bash-2.03# ./ldapsearch -b "ou=GEWorker,o=ge.com" -v -u -h myserver.com -p 3891 -d "cn=Directory Manager" -w xxxxx uid=Murthy dn|grep \^dn
The result I got was
compile with -DLDAP_DEBUG for debugging
Where could eb the wrong?
Murthy

Similar Messages

  • How to get "Count" from CAF's Application Service

    hi
    i want know how many data in my entity, i can use "findAll" and read the List's size.
    but it will waste resource.
    have any other way to get the count from entity?

    seem no way.

  • Getting counts from detail tables

    I have multiple record bock that displaye a list of cell ids and their attributes; each record also displays record counts of its 3 detail tables.
    Originally, the POST-QUERY trigger select the counts (3 detail tables) as part of the data block for each record (or cell id). There are over 16K records, so each record query issues 3 selects. The whole query toke over a minute. I was asked to improve the retrieval time.
    At first I thought perhaps I could put the 3 counts in 3 separate data blocks and issue one query each in a "select cell_id, count(*). . . group by cell_id" but scrolling would not synchronize with the other blocks. So I dropped that idea.
    Next, I added a program unit from which the WHEN-NEW-FORM-INSTANCE trigger calls after execute_query. It issues "select cell_id, count(*). . . group by cell_id" (one for each detail table) and fills the count columns in the original data block. However I need to set the block property Query All Records to YES so that the cell ids and attributes are filled first. That means that before the form comes up it has to retrieve all records. That saves me about 10-15 seconds od retrieval time and I lose the ability to quickly bring up the form.
    Then I looked at using dfferent Query Data Source Types. I don't think I could do one query with counts of detail tables. Besides, some items (attrinutes) of the cell are upate-able.
    Any ideas and suggestions will be appreciated.

    Yes. I suggested adding columns to the master tables and introduce stored triggers.
    Since the change is not trivial, according to management, they put in on hold.I'm not sure if you misunderstood my suggestion or were responding to a different post. The query I wrote was for counting the detail records on the fly rather than populating new columns. If you include the counting in your main query then you will probably not have a much slower query than if you don't show any counts at all. Scrolling through the block will be no slower than if you had no counts, because no extra processing needs to be done. (You'll still have to fetch the detail blocks for each row, so moving to the last record will still be slow - that's a bad indicator of the performance of a query.)
    For example, fetching the objects for each user takes 5 seconds. When I include the number of tables, indexes and constraints for each user within the query the time only goes up to just under 9.
    SQL> set autot trace stat
    SQL> set timing on
    SQL> SELECT
      2    owner,
      3    object_name,
      4    object_type
      5  FROM all_objects ao;
    39062 rows selected.
    Elapsed: 00:00:05.13
    Statistics
           4656  recursive calls
              0  db block gets
          85106  consistent gets
              0  physical reads
              0  redo size
        1469372  bytes sent via SQL*Net to client
          29021  bytes received via SQL*Net from client
           2606  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
          39062  rows processed
    SQL> SELECT
      2    owner,
      3    object_name,
      4    object_type,
      5    (SELECT Count(*) FROM all_tables WHERE owner = ao.owner) count_tables,
      6    (SELECT Count(*) FROM all_indexes WHERE owner = ao.owner) count_indexes,
      7    (SELECT Count(*) FROM all_constraints WHERE owner = ao.owner) count_constraints
      8  FROM all_objects ao;
    39062 rows selected.
    Elapsed: 00:00:08.86
    Statistics
           4656  recursive calls
              0  db block gets
         270299  consistent gets
              0  physical reads
              0  redo size
        1684042  bytes sent via SQL*Net to client
          29021  bytes received via SQL*Net from client
           2606  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
          39062  rows processed
    SQL> If you populate the counts in post-query then the process is similar to the block below. I tried to get a timing and stats for this but it took over 15 minutes so I shut it down.
    DECLARE
    ct NUMBER;
    ci NUMBER;
    cc NUMBER;
    BEGIN
      FOR ao IN (SELECT owner, object_name, object_type FROM all_objects)
      LOOP
        SELECT Count(*) INTO ct FROM all_tables WHERE owner = ao.owner;
        SELECT Count(*) INTO ci FROM all_indexes WHERE owner = ao.owner;
        SELECT Count(*) INTO cc FROM all_constraints WHERE owner = ao.owner;
      END LOOP;
    END;Creating a view on the query and writing the "instead of" triggers is hopefully a trivial enough operation that management won't get in the way. Then you'll be able to update the block.

  • Problem to get count from resultset with select count(1) like query

    Hi,
    The snippet of code is like this ...!
    preparedStatement = connection.prepareStatement("select count(1) as count from acf_users where acf_user_name like ? and acf_user_password like ?");
    preparedStatement.setString(1,stringUsername);
                   preparedStatement.setString(2,stringPassword);
                   resultSet = preparedStatement.executeQuery() ;
                   System.out.println("The ResultSet Count checkUser() : "+resultSet.getString("count"));
                   preparedStatement.close();
    But there is a SQLException like :
    java.sql.SQLException: ResultSet.next was not called
    I want to extract and check the count in the program..
    Does anyone has the solution, comments on this.
    Thanks in Advance,
    -Sachin

    Thanks a lot to have a look on it :
    I got the solution on it as :
    preparedStatement = connection.prepareStatement("select count(*) as total from acf_users where acf_user_name like ? and acf_user_password like ?");
                   preparedStatement.setString(1,stringUsername);
                   preparedStatement.setString(2,stringPassword);
                   resultSet = preparedStatement.executeQuery() ;
    resultSet.next();
                   System.out.println("The ResultSet checkUser() : "+resultSet.getInt("total"));
    The important line is :
    resultSet.next()
    Thanks once again,
    Sachin !

  • How to get count from new enhanced for loop

    Is there a better way to determine the count when new enhanced for loop is used as follows:
    String[] test = new String[]{"1","2","3"};
    int count = 0;
    for(String i: test)
    count++;
    system.out.println("count: "+count);
    }

    There are cases where I need to use the count inside
    the for loop. I can keep track of the count by using
    the increment. But, then I would rather using the old
    for loop. Go ahead and use it. Are you under the assumption that the old form should be avoided?
    There is no saving in term of efficiency and readability.If there is any added efficiency in the "for each" form of the loop, it is on the micro level, and you would never notice it.
    As far as readability, look at some of the crazy solutions you've been given to avoid the general for loop, then reconsider which is more readable.

  • Getting Count from Sheet1 based on criteria Possibly use of COUNTIF

    I have a workbook with two sheets.
    Sheet1 has the data and Sheet2 is a summary sheet I am able to use CountIF to pull the car count based on model using =COUNTIF(Inventory!B:B,"NIssan" (col C sheet2). My challenge is populating col D, ColE, ColF and ColG. Hope someone can help me
    with the correct fomula for these.

    I'd create a helper column, for example in column Z on the Inventory sheet.
    In Inventory!Z2: =(E2=G2)
    Fill down to the end of the data.
    On the Summary sheet:
    In C2: =COUNTIF(Inventory!B:B,B2)
    In D2: =COUNTIFS(Inventory!B:B,B2,Inventory!Z:Z,TRUE)
    In E2: =COUNTIFS(Inventory!B:B,B2,Inventory!Z:Z,FALSE)
    In F2: =COUNTIFS(Inventory!B:B,B2,Inventory!H:H,"CA")
    In G2: =COUNTIFS(Inventory!B:B,B2,Inventory!H:H,"WA")
    Select C2:G2 and fill down as far as needed.
    Regards, Hans Vogelaar (http://www.eileenslounge.com)

  • Getting data from infotype

    Hello Experts!
    I am a beginner in ABAP programming and I have problem with one of my task.
    I would like to get all users first and last names from infotype p0002. I've created a class, and method but only thing I've found in the Internet was something like this:
      DATA: lt_data     TYPE REF TO data,
             return      LIKE sy-subrc.
       FIELD-SYMBOLS: <table>  TYPE STANDARD TABLE.
       CREATE DATA lt_data TYPE STANDARD TABLE OF PA0002.
       ASSIGN lt_data->* TO <table>.
       CALL FUNCTION 'HR_READ_INFOTYPE'
       EXPORTING
         pernr       = '3'
         infty       = '0002'
         begda       = '18000101'
         endda       = '99991231'
       IMPORTING
         subrc       = return
       TABLES
         infty_tab   = <table>
       EXCEPTIONS
         infty_not_found = 1
         OTHERS          = 2.
       IF sy-subrc <> 0.
         MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                 WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
       ELSE.
         me_it = <table>.
       ENDIF.
    any suggestions how I can use it for all users and how to get data from the result? or is it useless for this task? help please

    Hi Andrew,
    There is absolutely no problem with the query i.e. everyone have a beginning and it is upon us how we take it to final stage.
    Leave things apart, the answer to your query is suggested below.
    Structure:
    TYPES: Begin of typ_pa0002,
                    pernr type pernr_d,               "Personnel No.
                    begda type begda,                "Begin Date
                    endda type endda,                "End Date
                    nachn type PAD_NACHN,    "Last Name
                    vorna type PAD_VORNA,     "First Name
                    namzu type namzu,               "Salutation
                 end of typ_pa0002,
    typ_t_pa0002 type standard table of typ_pa0002 initial size 0. "Table Type Definition
    Data:  l_it_pa0002 type typ_t_pa0002,     "IT for PA0002     " Internal Table Definiton
              lv_pernr type pernr,
              lv_begda type sy-datum,
              lv_endda type sy-datum.
    "Data Declaration
    lv_pernr = '3'.
    lv_begda =.'18000101'.
    lv_endda = '99991231'.
    "Data Retieval from PA0002 DB Table
    select pernr
              begda
              endda
              nachn
              vorna
              namzu
              from pa0002
              into table it_pa0002
              where   pernr = lv_pernr
                   and endda GE lv_endda 
                   and begda LE  lv_begda.
    Please validate the same at your end and let me know in case you require any further inputs from my end.
    BR/Thanks
    Pranav Agrawal    

  • Getting the record count from result set

    i'm retreiving the result set using the executeQuery method, now i want to know how many records are there in the result set, that is the record count of the result set.
    one solution to that is to first use the executeUpdate and then use the executeQuery but i think that is not the right way.
    so please tell me is there any method in jdbc to get that thing done
    Tanx

    Hi
    Do you know if your DB supports "insensitive scrolling"?
    SQL generally do, but some don't - I had the same problem with the
    open source version of Interbase from Phoenix...
    Anyway - try creating your statement this way:
    public Statement createStatement(int resultSetType, int resultSetConcurrency)
    throws SQLException
    ...where resultset type should be:
    ResultSet.TYPE_SCROLL_INSENSITIVE
    Then you can do this:
    ResultSet rs = stm.executeQuery(q);
    int size = rs.last(); //this what you looking for?
    rs.beforeFirst();
    while(rs.next()){
    }

  • How to get total number of result count for particular key on cluster

    Hi-
    My application requirement is client side require only limited number of data for 'Search Key' form total records found in cluster. Also i need 'total number of result count' for that key present on the custer.
    To get subset of record i'm using IndexAwarefilter and returning only limited set each individual node. though i get total number of records present on the individual node, it is not possible to return this count to client form IndexAwarefilter (filter return only Binary set).
    Is there anyway i can get this number (total result size) on client side without returning whole chunk of data?
    Thanks in advance.
    Prashant

    user11100190 wrote:
    Hi,
    Thanks for suggesting a soultion, it works well.
    But apart from the count (cardinality), the client also expects the actual results. In this case, it seems that the filter will be executed twice (once for counting, then once again for generating actual resultset)
    Actually, we need to perform the paging. In order to achieve paging in efficient manner we need that filter returns only the PAGESIZE records and it also returns the total 'count' that meets the criteria.
    If you want to do paging, you can use the LimitFilter class.
    If you want to have paging AND total number of results, then at the moment you have to use two passes if you want to use out-of-the-box features because LimitFilter does not return the total number of results (which by the way may change between two page retrieval).
    What we currently do is, the filter puts the total count in a static variable and but returns only the first N records. The aggregator then clubs these info into a single list and returns to the client. (The List returned by aggregator contains a special entry representing the count).
    This is not really a good idea because if you have more than one user doing this operation then you will have problems storing more than one values in a single static variable and you used a cache service with a thread-pool (thread-count set to larger than one).
    We assume that the aggregator will execute immediately after the filter on the same node, this way aggregator will always read the count set by the filter.
    You can't assume this if you have multiple client threads doing the same kind of filtering operation and you have a thread-pool configured for the cache service.
    Please tell us if our approach will always work, and whether it will be efficient as compared to using Count class which requires executing filter twice.
    No it won't if you used a thread-pool. Also, it might happen that Coherence will execute the filtering and the aggregation from the same client thread multiple times on the same node if some partitions were newly moved to the node which already executed the filtering+aggregation once. I don't know anything which would even prevent this being executed on a separate thread concurrently.
    The following solution may be working, but I can't fully recommend it as it may leak memory depending on how exactly the filtering and aggregation is implemented (if it is possible that a filtering pass is done but the corresponding aggregation is not executed on the node because of some partitions moved away).
    At sending the cache.aggregate(Filter, EntryAggregator) call you should specify a unique key for each such filtering operation to both the filter and the aggregator.
    On the storage node you should have a static HashMap.
    The filter should do the following two steps while being synchronized on the HashMap.
    1. Ensure that a ConcurrentLinkedQueue object exists in a HashMap keyed by that unique key, and
    2. Enqueue the total number count you want to pass to the aggregator into that queue.
    The parallel aggregator should do the following two steps while being synchronized on the HashMap.
    1. Dequeue a single element from the queue, and return it as a partial total count.
    2. If the queue is now empty, then remove it from the HashMap.
    The parallel aggregator should return the popped number as a partial total count as part of the partial result.
    The client side of the parallel aware aggregator should sum the total counts in the partial result.
    Since the enqueueing and dequeueing may be interleaved from multiple threads, it may be possible that the partial total count returned in a result does not correspond to the data in the partial result, so you should not base anything on that assumption.
    Once again, that approach may leak memory based on how Coherence is internally implemented, so I can't recommend this approach but it may work.
    Another thought is that since returning entire cached values from an aggregation is more expensive than filtering (you have to deserialize and reserialize objects), you may still be better off by running a separate count and filter pass from the client, since for that you may not need to deserialize entries at all, so the cost on the server may be lower.
    Best regards,
    Robert

  • Getting statistics from multiple tables using conditional expressions (e.g. combining min, count, sum, etc) in PHP/MySQL

    Hi,
    I'm trying to get statistics from a variety of related tables
    where the statistical counts are based on comparing the value on
    one table with an equivalent value on a second table (and I want to
    view the results grouped by time period, day, week, month, etc);
    e.g.
    Consider two tables - Customer & Customer_Action which
    are related as a one-to-many (one customer can take many actions):
    Customer: id, create_date, customer_name, etc.
    Customer_Action: id, customer_id, create_date, action, etc.
    If the customer took their first action at the same time as
    they registered on the system (i.e. if the customer record was
    created at the same time as the very first action record)
    YES_count is incremented by 1 else
    NO_count is incremented by 1
    So running the query against the database the report would
    look something like:
    Customers Yes No
    January 8 5 3
    February 14 9 5 .... Etc.
    I've tried this around a number of different ways but always
    seem to end up with double counting in one way or another: see this
    sample data
    Customer Create_Date Action_Date
    01 05/07/2008 12:36 05/07/2008 12:36
    01 05/07/2008 12:36 28/08/2008 22:22
    02 10/07/2008 12:04 10/07/2008 12:04
    03 10/07/2008 12:12 10/07/2008 12:12
    This should give me
    Count Yes No
    July 3 3 0
    ...... but I get always get a customer counts of 4 2 2!
    My current statement is .....
    SELECT count( m2u_Customer.id ) AS Customer,
    min( m2u_Customer_Action.action_date ) AS 'Action_Date',
    DATE_FORMAT( m2u_Customer.create_date, '%m-%M' ) AS Month,
    sum(case when m2u_Customer.create_date =
    m2u_Customer_Action.create_date then 1 else 0 end) as Yes,
    sum(case when m2u_Customer.create_date !=
    m2u_Customer_Action.create_date then 1 else 0 end) as No
    FROM m2u_Customer
    LEFT JOIN m2u_Customer_Action ON ( m2u_Customer.id =
    m2u_CustomerAction.customer_ id )
    WHERE m2u_Customer.create_date > '2008-07-02'
    AND m2u_Customer.create_date < '2008-08-01'
    GROUP BY DATE_FORMAT( m2u_Customer.create_date, '%m-%M' )
    Can this be done?
    Regards.
    Patrick

    In the default php.ini is set open_basedir which limits work with php only to few directories (and directories bellow them). There is set /srv/http, /home,/tmp and /usr/share/pear by default.
    To allow your vhost you should add /data/www or set empty value.

  • Get the record count from a query

    Hi,
    does anyone know how to get the record count from a sql query?
    e.g: I've got a ResultSet from the Statement.excuteQuery(), and I want to know how many records this ResultSet contains, how to get this?
    I'd read thoughout the documents of Statement and ResultSet, but couldn't find a solution, do I have to use another seperate query such as "select count(*)" to do this?
    thanks.
    Yang Liu

    If you are not using a scrollable result set then the following is the best way to do it.
    there are several key words in SQL that can be used, the one you are interested in is count();
    so if your query at the moment is
    "select col1, col2, col3 from my_table where col2=? and col3=?"you can work out how many rows will be returned by executing this command first
    "select count(col1) from my_table where col2=? and col3=?"this will return a result set with one row and one column, you can get the row count as follows:
    ResultSet rs = ps.executeQuery();
    int rowCount = rs.getInt(1);I hope this helps :)

  • File Adapter - how to get the file count from a folder

    Hi All,
    I have a requirement that have to poll a directory when the file count is reached to number N (ex:number of files avilable in folder is 5) otherwise it should wait and not pick any of the files. Is it possible to get the file count from a folder using file adapter ?? otherwise please suggest me an approach to achieve this requirement.
    Thanks,
    JJ

    Hi Sarath,
    Thank you for your reply.
    Go with the list files operation of file adapter it will gives you the number of files in the specified folder as you given. . - this step is already done.
    When the number of files reaches your count startup your webservice that which can polls the files. . . - how can i acheive this?? Have to poll the directory and process the number files - please let me know, what could be added to the webservice which is being invoked after cheking file count from parent process.
    The reason for the above question is - we cannot use ReadFile operation in second webservice because it will be automatically triggered when the file is avilable. Also SyncRead operation supports reading one file in b/w bpel process. Kindly explain me the implementation steps.
    Thanks,
    JJ

  • How to get the Node Value from XmlValue result?

    Hi ,
    I am not able to get the Node Value from the result. In my XQuery im selecting till a Node, if i change my query as
    collection('PhoneBook')/phone_book/contact_person/address/string()", qc);
    im getting the node value, but here the problem is its not a Node so i cannot get the Node name.
    So how can i get the Node Name and Node value together?
    any help please ????
    XML :
    <?xml version="1.0" encoding="UTF-8"?>
    <phone_book>
    <contact_person>
    <name>
    <first_name>Michael</first_name>
    <second_name>Harrison</second_name>
    </name>
    <address city="yyyyy" pincode="600017" state="xxxxx">
    176 Ganesan street, Janakinagar, alwarthirunagar
    </address>
    </contact_person>
    <phone_number type="mobile">9881952233</phone_number>
    <phone_number type="home">044-24861311</phone_number>
    <phone_number type="office">080-12651174</phone_number>
    </phone_book>
    Code:
    XmlQueryContext qc = manager.createQueryContext();
    XmlResults rs = manager.query
    ("collection('PhoneBook')/phone_book/contact_person/address", qc);
    while(rs.hasNext()){
    XmlValue val = rs.next();
    System.out.println(val.getNodeName() + " = [ " + val.getNodeValue() + " ] ");
    Output
    address = [  ]

    You are right, this seemed un-intuitive to me too, but I finally understood how it's done.
    The "value" of a node is actually the total amount of text that is not contained in any of the node's child nodes (if any). So a node with child nodes can still have text value.
    To get the 'value' of an element node, you must therefore concatenate the values of all children of type "XmlValue::TEXT_NODE", of that node. Try it.
    In your example, the <address> node has no child elements, my guess is that BDB XML stores the address string "176 Ganesan street, Janakinagar, alwarthirunagar" inside a child node of <address> node (of type XmlValue::TEXT_NODE) because you wrote the string on a separate line.

  • Select Count(*) from Sample_table - how to get the count using JDBC?

    Hi All,
    It would be glad if anyone could help me with this. The problem is that I have to get the 'count' of records selected from a arbitrary table say, 'sample_table'. Is that possible to form the SQL in JDBC as
    Select Count(*) from Sample_table
    and get the value of the count? If yes, how?
    Thanks in advance
    Prabz

    stmt = con.createStatement();
    ResultSet recordcnt_rs = stmt.executeQuery("Select Count (*) as record_ctr From Sample_table");
    recordcnt_rs.next();     
    record_ctr = recordcnt_rs.getInt("record_ctr");
    hope this helps.

  • How to get the FILE COUNT from File directory

    Hello,
    i have to develop a scenario like, get  the file count from source file directory and validate whether the file count is 5 or not. if 5 files exist i need to process those 5 files to DB tables. if file count is not equal to 5 then i need to send a mail to customer that files are missed at source directory. (subject as files were missed at source directory and in content i need to display the file names exist at source file directory. So that missed file will be generated by the customer based on this mail).
    Could you please let me know how to get the count of files from source file directory. if it is possible only with UDF please provide the Java code
    Best Regards,
    SARAN

    Do these files have some fixed names?
    Can you try to use the option Advanced Selection For Source File to make XI  pick all 5 files in one shot?
    Check this blog on the same -
    /people/mickael.huchet/blog/2006/09/18/xipi-how-to-exclude-files-in-a-sender-file-adapter
    If this is not a option - BPM sounds the only possible way.
    Regards,
    Bhavesh

Maybe you are looking for

  • Renaming the Physical Filename for Datafiles in SQL Server 2008

    Can anyone tell me how to change the physical filename of the datafiles? There doesn't seem to be any documentation on this, yet its quite easy to change the logical filename.

  • AE Composistion Settings for DVCPRO HD footage?

    Slightly unrelated but giving it a shot anyways . I have some DVCPRO HD footage. Here's the clip settings for it (digitized using Final Cut Pro). Vid Rate: 23.98 fps, Frame Size 960 x 720, Compressor DVC PRO HD 720p60, Data Rate 5.5 MB/sec, Pixel Asp

  • Test Data For Reservation

    Hi experts,                    I'm very new(fresher) to Reservation.I want to learn how to create  reservation in MB21. Here i'm unable to pass the correct data.It is asking the date,movement type,plant based on the movement type it is asking g/l acc

  • Wsrp-requireRewrite for URLs in resource response ?

    I'm using Portal 10.1.4 serving WSRP content from a portlet producer running on 10.1.3.2 (JDev embedded OC4J). I want to use an AJAX resource request to serve a fragment of portlet markup containing further portlet and AJAX URLs. URL rewriting for fu

  • Market tracking calculations

    I am starting a market strategy with $10,000.  Every week I may be selling or buying any or all of the stocks, but will never hold more than 5.  I would like to set up automated calculations.  The idea behind the strategy is that i originally invest