Getting a record count in a query using UNIQUE

I need to know how to grab a record count for a query so I can pass it back into the recordset.
This select query uses UNIQUE to rollup the 555 records to 125 unique rows.
But how would I do a record count.
Do I pass the query to a cursor and then count the records in the cursor?
Please detail your help please.
Thank you in advance.

SELECT unique
     CE.DATE_OF_SERVICE AS DOS_FROM
     ,CE.SERVICE_END_DATE AS DOS_TO
     ,CE.EVENT_SERVICE AS SERVICE_TYPE
     ,CN.CREATE_DATE_TIME
     ,CN.CASE_NOTE_ID
     ,CN.CASE_ID
     ,CN.EVENT_ID
     ,CN.REASON
     ,CN.CREATOR_USER_ID AS CREATOR_ID_USED
     ,CN.ROWID AS ROW_ID
     ,(SELECT Retrieve_Note2(CN.CASE_ID,CN.CASE_NOTE_ID) from DUAL) AS NOTE
FROM
     MEMBER_TO_PATIENT MTA,
     CARE_EVENT CE,
     CASE_NOTES CN
WHERE
     MTA.SUBSCRIBER_LID = '1260016473015' AND
     MTA.CASE_ID = CN.CASE_ID AND
     CN.EVENT_ID = CE.EVENT_ID
ORDER BY
     CN.CASE_NOTE_ID DESC

Similar Messages

  • 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 :)

  • How to return the record count of a query to a number variable

    How would I get the record count from a query without using a cursor to step through the query and count the records individually?
    query: select * from table1 where column1 = column2
    How would I get the record count of the query above?
    thanks,
    michelle

    I figured it out
    select count(*) into theCount
    from ( select * from table1 where column1=column2 );
    thanks,
    michelle

  • Problem in getting update records count while executeBatch()

    hi,
    I have used "Select in Insert" queries for migrating data from one table to another.
    like
    INSERT INTO TABLE1 (COL1, COL2)
    SELECT COL1,COL2,... FROM TABLE2
    WHERE COL1 = ... AND COL2 = ...;
    Case 1:
    I added these statements as addBatch() & at the end i execute method " executeBatch()". It returned the array of integer having record count for each query respectively.
    But that count was always be -2 i.e. SUCCESS_NO_INFO.
    Case 2:
    If i run the same code with executeUpdate() method , it returned me the correct number of records counts that are inserted into the table.
    I cudn't able to understand that it is failing for case1.
    Can anybody tell the reason for this behaviour .......................
    Edited by: user11187328 on Mar 17, 2010 3:45 AM
    Edited by: user11187328 on Mar 17, 2010 3:46 AM

    hi,
    Thanks again for a correct reply but can u also tell me tht which jar i needs to included.
    There are so many jar files & should i remove old jar files or jvm auto picks the updated jar file.
    Following jar files are shown on the link:::
    ojdbc5.jar (1,996,228 bytes) - Classes for use with JDK 1.5. It contains the JDBC driver classes, except classes for NLS support in Oracle Object and Collection types.
    ojdbc5_g.jar (3,081,328 bytes) - Same as ojdbc5.jar, except that classes were compiled with "javac -g" and contain tracing code.
    ojdbc6.jar (2,111,220 bytes) - Classes for use with JDK 1.6. It contains the JDBC driver classes except classes for NLS support in Oracle Object and Collection types.
    ojdbc6_g.jar (3,401,519 bytes) - Same as ojdbc6.jar except compiled with "javac -g" and contains tracing code.
    ojdbc5dms.jar (2,429,777 bytes) - Same as ojdbc5.jar, except that it contains instrumentation to support DMS and limited java.util.logging calls.
    ojdbc5dms_g.jar (3,101,875 bytes) - Same as ojdbc5_g.jar, except that it contains instrumentation to support DMS.
    ojdbc6dms.jar (2,655,741 bytes) - Same as ojdbc6.jar, except that it contains instrumentation to support DMS and limited java.util.logging calls.
    ojdbc6dms_g.jar (3,423,263 bytes) - Same as ojdbc6_g.jar except that it contains instrumentation to support DMS.
    orai18n.jar (1,656,280 bytes) - NLS classes for use with JDK 1.5, and 1.6. It contains classes for NLS support in Oracle Object and Collection types. This jar file replaces the old nls_charset jar/zip files.
    demo.zip (603,363 bytes) - contains sample JDBC programs.

  • Get particular item count in sharepoint list using designer Workflow

    How to get specific item count in sharepoint list using designer Workflow 2013.
    For Example 
    Title  Count
    x        1
    y        1
    x        2
    x        3

    HI Thiru,
    Can you please elaborate your problem. Is that Title and count are your list columns you want to fetch the value of count column based on title?
    If my interpretation in not wrong, then it's not possible in SPD with the case you have mentioned in your question as Title='x' is having 3 different entries and SPD activity will always return first matching item and ignore the rest with warning message.
    Regards,
    Brij K

  • How to get the record count printed for the report in the Dashboards

    Hi,
    I would like to get the record count printed at the bottom of every dashboard report like:
    < 1 - 25 of 6300 > instead of < 1 - 25 >
    Any help is appreciated
    Regards
    B

    I have tried the following formula which identifies the lowest grain but it does not seem to give me correct result.. I am not getting the correct count. I am getting as 3.A work order can be updated only once at one point of time.hence the formula
    MAX(RCOUNT(CAST("SR Wo Fact"."Crm Wo Number" AS CHAR) ||CAST("SR Wo Fact"."PSC Timestamp" as char)))
    I tried only MAX(RCOUNT(1)), but I was able to get the record count as corect for Administrator but not for other users.
    Has anyone come across this scenario.
    Thanks Shravan
    Edited by: 786443 on Aug 19, 2010 10:22 AM

  • Record count not matching when using HS while querying.

    Hello,
    We are using 10gr2.
    I created a Database link connecting to lotus notes using HETROGENEOUS SERVICES and ODBC.
    When we query the table in Lotus Notes using database link oracle is showing less records.
    For example.
    Lotus Notes database have a table which contains 873 records.
    When we query this table from oracle we are getting the count of 722 records.
    Any ideas why this is happening.
    Thank you for the help.
    Regards
    Seshadri Thope

    Oracle Corporation --- THURSDAY JAN 29 2009 10:34:23.786
    Heterogeneous Agent Release
    10.2.0.4.0
    (0) hoagprd (2): ; hoagprd Entered.
    (0) HOACONN.C (270): ; [Generic Connectivity Using ODBC] version: 10.2.0.0.0080
    (0) HOACONN.C (323): ; Class version: 300
    (0) hoagprd (2): ; hoagprd Exited with retcode = 0.
    (0) hoainit (3): ; hoainit Entered.
    (0) (0): ; connect string is: defTdpName=DATABASEA;SYNTAX=(ORACLE8_HOA, BASED_ON=ORACLE8, IDENTIFIER_QUOTE_CHAR="", CASE_SENSITIVE=CASE_SENSITIVE_QUOTE);BINDING=<navobj><binding><datasources><datasource name='DATABASEA' type='ODBC' connect='socrates'><driverProperties disableExtendedFetch='true'/></datasource></datasources><remoteMachines/><environment><optimizer noFlattener='true'/><misc year2000Policy='-1' consumerApi='1' codepage='WE8ISO8859P15' sessionBehavior='4'/><queryProcessor parserDepth='2000' tokenSize='1000' noInsertParameterization='true'
    noThreadedReadAhead='true' noCommandReuse='true'/><debug generalTrace='true'/></environment></binding></navobj>
    (0) ORACLE GENERIC GATEWAY Log File Started at 2009-01-29T10:34:24
    (0)
    (0) hoainit (3): ; hoainit Exited with retcode = 0.
    (0) hoalgon (7): ; hoalgon Entered. name = .
    (0) Created new ODBC connection (32056720)
    (0) hoalgon (7): ; hoalgon Exited with retcode = 0.
    (0) hoaulcp (4): ; hoaulcp Entered.
    (0) hoaulcp (4): ; hoaulcp Exited with retcode = 0.
    (0) hoauldt (5): ; hoauldt Entered.
    (0) hoauldt (5): ; hoauldt Exited with retcode = 0.
    (0) hoabegn (9): ; hoabegn Entered. formatID = 306206, hoagttln = 38, hoagttid = DATABASEA.e53cf895.2.35.27286, hoagtbln = 10, hoagtbid = , tflag = 0, initial = 1
    (0) hoabegn (9): ; hoabegn Exited with retcode = 0.
    (0) hoadtab (26): ; hoadtab Entered. count = 1
    (0) hoadtab (26): ; schema_name = , table_name = TABLEA
    (0) odbc_rec: select * from "TABLEA"
    (0) nvOUT (D:\Work_Builds\connect_5010\src\qp\QP_SQTXT.C 89): select NON_UNIQUE, INDEX_NAME, TYPE, SEQ_IN_INDEX, COLLATION, CARDINALITY, COLUMN_NAME from NAV_PROC:SP_STATISTICS('DATABASEA', '%', 'TABLEA', 1, 0, 0) order by 3, 1, 2, 4
    (0) nvRETURN (D:\Work_Builds\connect_5010\src\qp\qpsynon.c 1171): -1
    (0) <<<<<<<<<<<<<<<<<<< Execution Strategy Begin <<<<<<<<<<<<<<<<<<<<<<<<<<<<
    (0) Original SQL:
    (0) select NON_UNIQUE , INDEX_NAME , TYPE , SEQ_IN_INDEX , COLLATION , CARDINALITY , COLUMN_NAME from NAV_PROC : SP_STATISTICS ( 'DATABASEA' , '%' , 'TABLEA' , 1 , 0 , 0 ) order by 3 , 1 , 2 , 4
    (0)
    (0)
    (0) Accessing saved query spec SP_STATISTICS()
    (0) from NAV_PROC DB
    (0)
    Execution Strategy End >>>>>>>>>>>>>>>>>>>>>>>>>>>>(0) HOAUTIL.C (1284): ; ------ hoadtab (hoat) -------:
    (0) HOAUTIL.C (1287): ; hoatnam: TABLEA, hoatnml: 20, hoatnrw: 711, hoatarl: 110000
    (0) HOAUTIL.C (1298): ; ------ hoadtab (hoai) -------:
    (0) HOAUTIL.C (1299): ; n_index_stat: 0
    (0) HOAUTIL.C (1249): ; -------- hoadtab for table TABLEA---------:
    (0) HOAUTIL.C (1250): ; hoadamsz: 22, hoadasiz: 22, hoadambr: 1, hoadabrc: 0, hoadawht: 5
    (0) HOAUTIL.C (1253): ; row 0 - hoadambl: 4000, hoadadty: 108, hoadaprc: 0, hoadacst: 0
    (0) HOAUTIL.C (1257): ; row 0 - hoadascl: 0, hoadanul: 1, hoadanml: 7, hoadanam: Subject, hoadabfl: 4000, hoadamod: 0
    (0) HOAUTIL.C (1253): ; row 1 - hoadambl: 4000, hoadadty: 108, hoadaprc: 0, hoadacst: 0
    (0) HOAUTIL.C (1257): ; row 1 - hoadascl: 0, hoadanul: 1, hoadanml: 11, hoadanam: DateCreated, hoadabfl: 4000, hoadamod: 0
    (0) HOAUTIL.C (1253): ; row 2 - hoadambl: 4000, hoadadty: 108, hoadaprc: 0, hoadacst: 0
    (0) HOAUTIL.C (1257): ; row 2 - hoadascl: 0, hoadanul: 1, hoadanml: 18, hoadanam: CustomerFacingUnit, hoadabfl: 4000, hoadamod: 0
    (0) HOAUTIL.C (1253): ; row 3 - hoadambl: 4000, hoadadty: 108, hoadaprc: 0, hoadacst: 0
    (0) HOAUTIL.C (1257): ; row 3 - hoadascl: 0, hoadanul: 1, hoadanml: 12, hoadanam: OFFERNUMBERS, hoadabfl: 4000, hoadamod: 0
    (0) HOAUTIL.C (1253): ; row 4 - hoadambl: 4000, hoadadty: 108, hoadaprc: 0, hoadacst: 0
    (0) HOAUTIL.C (1257): ; row 4 - hoadascl: 0, hoadanul: 1, hoadanml: 13, hoadanam: textedPricing, hoadabfl: 4000, hoadamod: 0
    (0) HOAUTIL.C (1253): ; row 5 - hoadambl: 4000, hoadadty: 108, hoadaprc: 0, hoadacst: 0
    (0) HOAUTIL.C (1257): ; row 5 - hoadascl: 0, hoadanul: 1, hoadanml: 22, hoadanam: textedShortDescription, hoadabfl: 4000, hoadamod: 0
    (0) HOAUTIL.C (1253): ; row 6 - hoadambl: 4000, hoadadty: 108, hoadaprc: 0, hoadacst: 0
    (0) HOAUTIL.C (1257): ; row 6 - hoadascl: 0, hoadanul: 1, hoadanml: 21, hoadanam: textedLongDescription, hoadabfl: 4000, hoadamod: 0
    (0) HOAUTIL.C (1253): ; row 7 - hoadambl: 4000, hoadadty: 108, hoadaprc: 0, hoadacst: 0
    (0) HOAUTIL.C (1257): ; row 7 - hoadascl: 0, hoadanul: 1, hoadanml: 14, hoadanam: textedBenefits, hoadabfl: 4000, hoadamod: 0
    (0) HOAUTIL.C (1253): ; row 8 - hoadambl: 4000, hoadadty: 108, hoadaprc: 0, hoadacst: 0
    (0) HOAUTIL.C (1257): ; row 8 - hoadascl: 0, hoadanul: 1, hoadanml: 18, hoadanam: textedAboutAuthors, hoadabfl: 4000, hoadamod: 0
    (0) HOAUTIL.C (1253): ; row 9 - hoadambl: 4000, hoadadty: 108, hoadaprc: 0, hoadacst: 0
    (0) HOAUTIL.C (1257): ; row 9 - hoadascl: 0, hoadanul: 1, hoadanml: 13, hoadanam: textedContent, hoadabfl: 4000, hoadamod: 0
    (0) HOAUTIL.C (1253): ; row 10 - hoadambl: 4000, hoadadty: 108, hoadaprc: 0, hoadacst: 0
    (0) HOAUTIL.C (1257): ; row 10 - hoadascl: 0, hoadanul: 1, hoadanml: 23, hoadanam: textedDiffByMedia_Print, hoadabfl: 4000, hoadamod: 0
    (0) HOAUTIL.C (1253): ; row 11 - hoadambl: 4000, hoadadty: 108, hoadaprc: 0, hoadacst: 0
    (0) HOAUTIL.C (1257): ; row 11 - hoadascl: 0, hoadanul: 1, hoadanml: 20, hoadanam: textedDiffByMedia_CD, hoadabfl: 4000, hoadamod: 0
    (0) HOAUTIL.C (1253): ; row 12 - hoadambl: 4000, hoadadty: 108, hoadaprc: 0, hoadacst: 0
    (0) HOAUTIL.C (1257): ; row 12 - hoadascl: 0, hoadanul: 1, hoadanml: 26, hoadanam: textedDiffByMedia_Internet, hoadabfl: 4000, hoadamod: 0
    (0) HOAUTIL.C (1253): ; row 13 - hoadambl: 4000, hoadadty: 108, hoadaprc: 0, hoadacst: 0
    (0) HOAUTIL.C (1257): ; row 13 - hoadascl: 0, hoadanul: 1, hoadanml: 23, hoadanam: textedDiffByMedia_Other, hoadabfl: 4000, hoadamod: 0
    (0) HOAUTIL.C (1253): ; row 14 - hoadambl: 4000, hoadadty: 108, hoadaprc: 0, hoadacst: 0
    (0) HOAUTIL.C (1257): ; row 14 - hoadascl: 0, hoadanul: 1, hoadanml: 10, hoadanam: BookStatus, hoadabfl: 4000, hoadamod: 0
    (0) HOAUTIL.C (1253): ; row 15 - hoadambl: 4000, hoadadty: 108, hoadaprc: 0, hoadacst: 0
    (0) HOAUTIL.C (1257): ; row 15 - hoadascl: 0, hoadanul: 1, hoadanml: 9, hoadanam: Published, hoadabfl: 4000, hoadamod: 0
    (0) HOAUTIL.C (1253): ; row 16 - hoadambl: 4000, hoadadty: 108, hoadaprc: 0, hoadacst: 0
    (0) HOAUTIL.C (1257): ; row 16 - hoadascl: 0, hoadanul: 1, hoadanml: 4, hoadanam: ISBN, hoadabfl: 4000, hoadamod: 0
    (0) HOAUTIL.C (1253): ; row 17 - hoadambl: 4000, hoadadty: 108, hoadaprc: 0, hoadacst: 0
    (0) HOAUTIL.C (1257): ; row 17 - hoadascl: 0, hoadanul: 1, hoadanml: 5, hoadanam: Pages, hoadabfl: 4000, hoadamod: 0
    (0) HOAUTIL.C (1253): ; row 18 - hoadambl: 4000, hoadadty: 108, hoadaprc: 0, hoadacst: 0
    (0) HOAUTIL.C (1257): ; row 18 - hoadascl: 0, hoadanul: 1, hoadanml: 7, hoadanam: Binding, hoadabfl: 4000, hoadamod: 0
    (0) HOAUTIL.C (1253): ; row 19 - hoadambl: 4000, hoadadty: 108, hoadaprc: 0, hoadacst: 0
    (0) HOAUTIL.C (1257): ; row 19 - hoadascl: 0, hoadanul: 1, hoadanml: 11, hoadanam: ProductSize, hoadabfl: 4000, hoadamod: 0
    (0) HOAUTIL.C (1253): ; row 20 - hoadambl: 4000, hoadadty: 108, hoadaprc: 0, hoadacst: 0
    (0) HOAUTIL.C (1257): ; row 20 - hoadascl: 0, hoadanul: 1, hoadanml: 12, hoadanam: DateModified, hoadabfl: 4000, hoadamod: 0
    (0) HOAUTIL.C (1253): ; row 21 - hoadambl: 4000, hoadadty: 108, hoadaprc: 0, hoadacst: 0
    (0) HOAUTIL.C (1257): ; row 21 - hoadascl: 0, hoadanul: 1, hoadanml: 15, hoadanam: ProductItemCode, hoadabfl: 4000, hoadamod: 0
    (0) hoadtab (26): ; hoadtab Exited with retcode = 0.
    (0) hoadafr (23): ; hoadafr Entered. id = 0.
    (0) hoadafr (23): ; hoadafr Exited with retcode = 0.
    (0) hoapars (15): ; hoapars Entered. stmtType = 0, id = 1.
    (0) nvOUT (D:\Work_Builds\connect_5010\src\qp\QP_SQTXT.C 89): SELECT COUNT(*) FROM "TABLEA" A1
    (0) nvRETURN (D:\Work_Builds\connect_5010\src\qp\qpsynon.c 1171): -1
    (0) SELECT COUNT(*) AS c000 FROM "TABLEA" "A1"
    (0)
    (0) <<<<<<<<<<<<<<<<<<< Execution Strategy Begin <<<<<<<<<<<<<<<<<<<<<<<<<<<<
    (0) Original SQL:
    (0) SELECT COUNT ( * ) FROM "TABLEA" A1
    (0)
    (0)
    (0) Accessing Database 'DATABASEA' with SQL:
    (0) SELECT COUNT(*) AS c000 FROM "TABLEA" "A1"
    (0)
    (0)
    Execution Strategy End >>>>>>>>>>>>>>>>>>>>>>>>>>>>(0) hoapars (15): ; hoapars Exited with retcode = 0.
    (0) hoaopen (19): ; hoaopen Entered. id = 1.
    (0) hoaopen (19): ; hoaopen Exited with retcode = 0.
    (0) hoadscr (16): ; hoadscr Entered. id = 1.
    (0) hoastmt.c (304): ; Array fetch size is: 1.
    (0) HOAUTIL.C (1249): ; ------ hoadscr() -------:
    (0) HOAUTIL.C (1250): ; hoadamsz: 1, hoadasiz: 1, hoadambr: 1, hoadabrc: 1, hoadawht: 5
    (0) HOAUTIL.C (1253): ; row 0 - hoadambl: 4, hoadadty: 8, hoadaprc: 10, hoadacst: 0
    (0) HOAUTIL.C (1257): ; row 0 - hoadascl: 0, hoadanul: 1, hoadanml: 8, hoadanam: $$CALC_1, hoadabfl: 4, hoadamod: 0
    (0) hoadscr (16): ; hoadscr Exited with retcode = 0.
    (0) hoaftch (21): ; hoaftch Entered. id = 1.
    (0) apiutil.c (0): ; hoaftch()::
    (0) apiutil.c (0): ; Column 0 - pszName: $$CALC_1, size: 4, id: 8, width: 0, scale: 0, flags: 12.
    (0) SELECT COUNT(*) AS c000 FROM "TABLEA" "A1"
    (0)
    (0) hoaftch (21): ; hoaftch Exited with retcode = 0, hoadabrc = 1.
    (0) hoaftch (21): ; hoaftch Entered. id = 1.
    (0) hoaftch (21): ; hoaftch Exited with retcode = 1403, hoadabrc = 0.
    (0) hoaclse (22): ; hoaclse Entered. id = 1.
    (0) hoaclse (22): ; hoaclse Exited with retcode = 0.
    (0) hoadafr (23): ; hoadafr Entered. id = 1.
    (0) hoadafr (23): ; hoadafr Exited with retcode = 0.
    (0) hoacomm (11): ; hoacomm Entered. keepinfo = FALSE, tflag = 1.
    (0) hoacomm (11): ; hoacomm Exited with retcode = 0.
    (0) hoalgof (8): ; hoalgof Entered. tflag = 1.
    (0) hoalgof (8): ; hoalgof Exited with retcode = 0.
    (0) hoaexit (6): ; hoaexit Entered.
    (0) hoaexit (6): ; hoaexit Exited with retcode = 0.
    (0) (0): ; Closing log file at THU JAN 29 10:38:55 2009.

  • How can I get record count with a query?

    In Client/Server pplication,the client send a query to server.
    How can server get record count by oracle call interface?
    Is it need execute "select count(*) from ...."?

    Yes.
    Either that or increment a counter for each record fetched and
    loop round until you hit the last record.
    The first method would be more efficient on large datasets.

  • Get estimated record count

    for pagination, we want to show the total pages. the way is to get the total count,then divided by the record number per page. The problem is its too expensive to get the total count.
    In pl/sql, we can get the estimated record count with
    select * from table(dbms_xplan.display_cursor(null,null,'ALLSTATS LAST')); but my question is how to get this number from application code, like java or php.
    Thanks,

    Hi,
    Though what you're trying to do can be achieved in three steps *(i)* importing of java.io.* and java.sql.* packages *(ii)* establishment of a connection using JDBC driver, and *(iii)* query execution, it would NOT be constructive for the fact that a SELECT statement (as stated in the above reply) will always be a part of the query sentence for the following reasons:
    (a) When objects are executed in Java, the first statement that is compiled is a SQL statement.
    (b) Parameters cannot be defined in SQL strings.
    Hence, as per my understanding, you can either stick to the existing approach or modify it as per the defined standards and not customized ones.
    Regards,
    Naveed.

  • Get the record count

    The Query below is part of a huge query. The snipet is just the part that I need to make a change.
    For the query below, how can I get the recordcount in the select inside the case statement? I want to only output the r_text when the record count of the select is zero (0) else make the output to r_text null
    select
    distinct a.style_id, b.sty, b.season, a.cust, a.ad_d, b.code,
    (case when b.code = 'MAKE' then
    (select min(t.value) from sn.age r, sn.text t
    where r.t_id = '18' and r.name = 'MTGNSL'
         and r.t_id = t.t_id
         and r.name = t.name and r.text_id = t.text_id
         and r.id_1 = a.id
    ) end) r_text,
    (case when b.code is null then 'Blank Code'
    when b.code = 'MAKE' then 'MAKE' end) err
         

    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 :)

  • 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()){
    }

  • Disk utility gets "invaild record count"

    Hello, Using Macbook pro running OSX 10.9.2
    Yesterday, i was using my computer searching internet, plugged it in and walked away for about 5 mins. Came back and tried to open iTunes. I 1st choose iTunes using the button w/ the 6 squares on it on the top row of keyboard. Nothing happen and iTunes did not open. 2nd I tried to open iTunes using the dashboard. Again nothing happen. I used the power button to shut down the computer. Then restarted, it came up with a window asking which language I would like to use. I choose English and then a new window opens with 4 choices; "Restore using Time machine", "Reinstall OSX", "Get online help" (which is how I am here now), and "use disk utility". I picked disk utlity and verified the disk which popped up a window say it "stopped and needed to be repaired. I hit the "repair buttom" and got a "Invaild record count" in red. It then stopped and said it could not be repaired.
    Tried to restore using the back-up/restore with Time machine. It found time machine, but on about the 4th screen it asks which volume I would like torestore to. Nothing comes up and just says "searching for disks" None ever come up. I quit disk utility and then choose "Start up disk" under the apple menu. It doesn't find anything. I tried the "command + option + P + R" nothing is different.
    So here I am. each new screen that comes up flickers a lot before clearing.
    Dead hard drive?
    Just can't find it?
    What's next?
    Thank you for being here to help
    Jody

    Thank you dominic23.
    I tried the instructions listed by Chris Watts1 and after running the /sbin/fsck_hfs -yprd /dev/disk0s2
    it never asked for a password just said "starting". After waiting a couple mintues it came back with the following: (which I have no idea what any of it means)
    journal_reply (/dev/disk0s2) returned 22
            using cacheBlockSize = 32K  cacheTotalBlock = 16384  cacheSize = 524288K.
    Executing fsck_hfs (version hfs-226.1.1).
    **Checking journaled HFS Plus volume.
    hfs_swap_BTNode: invalid forward link (0xA9812964)
    hfs_swap_BTNode: invalid backward link (0x0B69B6DB)
    hfs_swap_BTNode: invalid node kind (-124)
    hfs_swap_BTNode: invalid node height (42)
    hfs_swap_BTNode: invalid record count (0x3E6B)
    Invalid record count
    (3, 3)
    **The volume could not be verified completely.
    volume check failed with error 2
    volume type is pure HFS+
    Primary MDB is at Block 0 0x00
    Alternate MDB is at Block 0 0x00
    Primary VHB is at Block 2 0x02
    Alternate VHB is at Block 975093950 0x3a1ec0be
    Sector size = 512 0x200
    VolumeObject flags = 0x07
    total sectors for volume = 975093952 0x3a1ec0c0
    total sectors for embedded volume = 0x00
    CheckHFS returned -1317 , fsmodified = 0
    Does any of this mean anything to you?
    thank you again,
    Jody

  • Returning a count from a query using Union

    Hi. I'm attempting to select a count from this query and then display the total in a message, but I'm getting a 'Too many rows returned' (ORA-01422). Can anyone tell me how I can achieve a total for this query?
             SELECT nvl(count(*),0)
           INTO conflict_cnt
           FROM dropper_assign
           WHERE dropper_id = :dropper_vacations.dropper_id AND
                trunc(sched_date) between :begin_dt and :end_dt
              union                          
       SELECT nvl(count(*),0)
        FROM exfc.bundle a, splits b
        WHERE a.bundle = b.bundle AND
             b.dropper_id = :dropper_vacations.dropper_id AND
             trunc(a.actual_dt) between :begin_dt and :end_dt;
              call_alert.the_error('test: '||to_char(conflict_cnt));Any help would be greatly appreciated.

    Thanks Christian, I can know return to my favourite present occupation named HOLIDAYS ;)
    btw with count function as the first message
    WITH
      data AS
        SELECT
          COUNT(*) cnt
        FROM
          dual
          CONNECT BY level <= 10
        UNION
        SELECT
          COUNT(*) cnt
        FROM
          dual
          CONNECT BY level <= 20
    SELECT
      SUM(cnt)
    FROM
      data
    SUM(CNT)              
    30        
    /* and */
    WITH
      data AS
        SELECT
          COUNT(*) cnt
        FROM
          dual
          CONNECT BY level <= 10
        UNION ALL /****** returns me also 30 *****/
        SELECT
          COUNT(*) cnt
        FROM
          dual
          CONNECT BY level <= 20
    SELECT
      SUM(cnt)
    FROM
      data
    SUM(CNT)              
    30       result will defer only if both count return exactly the same value so definitely UNION ALL for that case or the simple solution I have provided before ...
    but leave it. that's enough messages for this thread ;)
    Jean-Yves
    Edited by: JeanYves Bernier on 9 août 2011 17:42

  • How to get locked records of a pernr while using PNP LDB

    is there any way to retrieve locked records of a pernr
    while using PNP LDB??currently the get pernr event is unable to load locked records of a pernr.

    Hi,
    PL use this piece of code in your Program..
    INITIALIZATION.
    PNP-SW-IGNORELOCKEDRECORDS = 'N'.
    Regards,
    Suresh Datti

  • How to get the record count before fetch

    CREATE PACKAGE demo_cur_pkg AS
    TYPE EmpName IS RECORD (name VARCHAR2(10));
    TYPE cur_type IS REF CURSOR RETURN EmpName;
    PROCEDURE open_emp_cur (
    curs IN OUT cur_type,
    dept_num IN NUMBER);
    END;
    CREATE PACKAGE BODY demo_cur_pkg AS
    CREATE PROCEDURE open_emp_cur (
    curs IN OUT cur_type,
    dept_num IN NUMBER) IS
    BEGIN
    OPEN curs FOR
    SELECT ename FROM emp
    WHERE deptno = dept_num
    ORDER BY ename ASC;
    END;
    END;
    After this package has been stored, you can open the cursor curs by calling the open_emp_cur stored procedure from your Pro*C/C++ program, and FETCH from the cursor in the program. For example:
    sql_cursor emp_cursor;
    char emp_name[11];
    EXEC SQL ALLOCATE :emp_cursor; /* allocate the cursor variable */
    /* Open the cursor on the server side. */
    EXEC SQL EXECUTE
    begin
    demo_cur_pkg.open_emp_cur(:emp_cursor, :dept_num);
    end;
    EXEC SQL WHENEVER NOT FOUND DO break;
    for (;;)
    EXEC SQL FETCH :emp_cursor INTO :emp_name;
    printf("%s\n", emp_name);
    Any solutioon is welcome

    Fail to understand why you want to introduce exception processing - e.g. use methodA for less than 10,000 rows and use methodB for 10,000 and more.
    Why not use methodC - optimal support for fetching, irrespective of whether there are 1 row to fetch, or a 100,000 rows?
    There is no best way for fetching a small number of rows versus a different best way for fetching more rows. There is a single optimal method - and this remains the same irrespective of the number of rows being returned.

Maybe you are looking for

  • Cost element creation

    Hi all, I'm exploring ways to create cost elements with batch input. In fact I need to generate cost element with category 90. Standard CO-settings (OKB2) are made to define a range of cost elements, but it doesn't let me define a range for statistic

  • LaCie D2 Firewire 800 drives not mounting.

    Hi guys, After an OS upgrade to 10.5 I can't mount any Firewire drives to desktop. In fact, they're not even listed in System profiler, the message "*Warning:Unable to list FireWire devices*" comes up in Firewire bus section. They worked fine under 1

  • Ipod frozen in disk mode

    Hi i wondered if anyone can help. I just switched the hold of my ipod and it wont switch on... it just says ok to disconnect.It wont reset and states that it is in disk mode. Thanks

  • Specify pool name in radius reply

    hello all . I have 2 pools of IPs on the router ans have dialup vdpn sessions on it , I need some specific users get from a pool and other users from the other pool. Can I return the pool name in the radius reply when the user is authenticating ? and

  • Removing Case-Sensitive HFS

    Dear all, I am using a MacBook Pro, and have been using this machine for so many months. When I started using it, I formatted it as Case-Sensitive HFS. However, by this time, Case-Sensitive is causing so many of my programs to not work correctly. So,