Select a range of rows?

I know I can edit SELECT TOP (200) to increase rows, but how can I select NEXT 200 rows or rows 200 thru 400? I have tried OFFSET, START AT, SKIP, etc.

Of course.
you can create a stored procedure like this
create PROCEDURE [dbo].[usp_GetPersons]
@rowsperpage int = 200
, @pagenumber int = 1
AS
BEGIN
SET NOCOUNT ON;
;with cte
as (
SELECT *, ROW_NUMBER() OVER (ORDER BY [BusinessEntityID]) AS RowNumber
FROM [Person].[Person]
select
from
cte
WHERE RowNumber BETWEEN ((@PageNumber-1)*@RowsPerPage)+1
AND @RowsPerPage*(@PageNumber)
SET NOCOUNT OFF;
END
and after that you can execute
EXEC [dbo].[usp_GetPersons] @rowsperpage = 200, @pagenumber = 1
go
with this results
and so on
EXEC [dbo].[usp_GetPersons] @rowsperpage = 200, @pagenumber = 2
go
I hope this will help you
P. Ceglie - "CIA - Is the main thing" ______________________________________________ Se alcuni post rispondono al tuo quesito(non necessariamente i miei), ricorda di contrassegnarli come risposta e non dimenticare di contrassegnare anche i post
utili. La community ringrazia :-)

Similar Messages

  • How do I select a range of rows from an internal table in the debugger?

    Hi,
    I have a case where I wanted to delete a range of rows (several thousand) from an internal table using the debugger.
    It seems that rows can only be selected one at a time by selecting (clicking) on the far left side of the row.
    This is cumbersome, if not impossible when wishing to delete several thousand rows. 
    Other tools, such as Excel for example, allow for selecting a range of rows by selecting the first row and then holding the SHIFT key and selecting the last row and all rows in between will be selected.
    I can't seem to find the combination of keys that will allow this in the table (or structure) tab of the debugger.
    Is it possible to select a range of rows without having to select each row one at a time?
    Thanks for your help,
    Andy

    While it's a Table Control and should/could have a button to select all fields (or visible fields)...I don't think we can do it right now...I know it's a pain to select each row one at a time...but I don't we have any more options...
    Greetings,
    Blag.

  • Select a range of rows to be displayed using ROWNUM

    I am trying to select a range of records to be displayed using Rownum
    It works using MINUS
    SQL> select rownum,department_id,department_name from departments where rownum <= 20
    minus
    select rownum,department_id,department_name from departments where rownum < 11;
    but does not work if a range is specified
    select rownum,department_id,department_name from departments where rownum >= 11 and rownum <= 20;
    What has gone wrong?
    Details of what I have tried are as follows:
    Connect to the sample schema HR
    SQL> connect hr/hr
    SQL> desc departments
    Name Null? Type
    DEPARTMENT_ID NOT NULL NUMBER(4)
    DEPARTMENT_NAME NOT NULL VARCHAR2(30)
    MANAGER_ID NUMBER(6)
    LOCATION_ID NUMBER(4)
    List all records in Departments
    SQL> select rownum,department_id,department_name from departments;
    ROWNUM DEPARTMENT_ID DEPARTMENT_NAME
    1 10 Administration
    2 20 Marketing
    3 30 Purchasing
    4 40 Human Resources
    etc......
    26 260 Recruiting
    27 270 Payroll
    27 rows selected.
    List the first 10 records in DEPARTMENTS
    SQL> select rownum,department_id,department_name from departments where rownum <= 10;
    ROWNUM DEPARTMENT_ID DEPARTMENT_NAME
    1 10 Administration
    2 20 Marketing
    etc.....
    10 100 Finance
    List row number from 11 to 20, but cannot no rows selected. Why?
    SQL> select rownum,department_id,department_name from departments where rownum >= 11 and rownum <= 20;
    no rows selected
    Use of MINUS can retrieve row number from 11 to 20
    SQL> select rownum,department_id,department_name from departments where rownum <= 20
    minus
    select rownum,department_id,department_name from departments where rownum < 11;
    ROWNUM DEPARTMENT_ID DEPARTMENT_NAME
    11 110 Accounting
    12 120 Treasury
    13 130 Corporate Tax
    14 140 Control And Credit
    15 150 Shareholder Services
    16 160 Benefits
    17 170 Manufacturing
    18 180 Construction
    19 190 Contracting
    20 200 Operations
    10 rows selected.

    For each row returned by a query, the ROWNUM pseudocolumn returns a number indicating the order in which Oracle selects the row from a table or set of joined rows. The first row selected has a ROWNUM of 1, the second has 2, and so on.
    Conditions testing for ROWNUM values greater than a positive integer are always false. For example, this query returns no rows:
    SELECT * FROM employees
    WHERE ROWNUM > 1;
    You can get the selected records based on the rownum using the inline query....
    SQL> select rownum, empno from emp;
    ROWNUM EMPNO
    1 7369
    2 7499
    3 7521
    4 7566
    5 7654
    6 7698
    7 7782
    8 7788
    9 7839
    10 7844
    11 7876
    ROWNUM EMPNO
    12 7900
    13 7902
    14 7934
    14 rows selected.
    SQL> select * from (select rownum rn, empno from emp) where rn > 2 and rn < 5;
    RN EMPNO
    3 7521
    4 7566

  • File Count with selected date range

    Hi,
    Our requirement is to get the file count with selected date by the user from two sharepoint date time controls i.e. dtp1 and dtp2 into the data table. I am able to get the file count of specific folder from Pages library through below code. Now need to get
    the selected date range from two date time picker controls and check with the item created by is within the date range. If yes I need to get the file count.
    So please share your ideas/thoughts to do the same.
    SPList list =
    wikiweb.Lists["Pages"];
                        SPFolderCollection oFolders
    = list.RootFolder.SubFolders["foldername"].SubFolders;
                        DataTable dt
    = new DataTable();
                        dt.Columns.Add("Column1");
                        DataRow dr;
                        if (oFolders.Count
    > 0)
                            foreach (SPFolder oFolder in oFolders)
     if (!oFolder.Name.Equals("Forms"))
                                    dr
    = dt.NewRow(); 
    dr["Column1"] = oFolder.ItemCount.ToString();
    dt.Rows.Add(dr);
    Regards,
    Sudheer
    Thanks & Regards, Sudheer

    Hi,
    I have modified the code as below
    if((DateTime)(oFolder.Item.File.TimeCreated>dtFromDate.SelectedDate)&&(DateTime)(oFolder.Item.File.TimeCreated<dtToDate.SelectedDate))
    But still it is throwing the error.
    Please share your ideas on the same.
    Regards,
    Sudheer
    Thanks & Regards, Sudheer

  • XML/XPath question--how to select a range of elements with XPath?

    Hi there,
    I have an XML DOM in memory. I need to do hold it and issue only parts of it to my client app in "pages". Each page would be a self-contained XML doc, but would be a subset of the original doc. So for instance the first page is top-level elements 1-5. 2nd page would be 6-10 etc. Is this solution best solved with XPath? If not, what's the best way? If so, I have the following question:
    Is there a way to use XPath to select a range of nodes based on position within the document? I know I can do an XPath query that will return a single Node based on position. So for example if I wanted the first node in some XML Book Catalog I could do XPathAPI.selectSingleNode(doc, "/Catalog/Book[position()=1]"); I could wrap the previous call in a loop, replacing the numeric literal each time, but that seems horribly inefficient.
    Any ideas? Thanks much in advance!
    Toby Buckley

    Your question is about marking a range of cells. 99% of the code posted has nothing to do with this. If you want to create a simple table for test purposes then just do:
    JTable table = new JTable(10, 5);
    JScrollPane scrollPane = new JScrollPane( table );
    getContentPane().add( scrollPane );
    In three line of code you have a simple demo program.
    When I leave the mouse button again, these bunch/range of cells shall stay "marked". table.setCellSelectionEnabled( true );
    and I'd like to obtain, say, a vector of a vector containing just those data marked beforeUse the getSelectedRows() and getSelectedColumns() methods for this information. I would suggest you create a Point object to reflect the row/column position and then add the point to an ArrayList.

  • Delete a range of rows in Oracle Table

    How do i delete a range of values in Oracle Table using SQL Pus. For example i have iwanted to delete rows with user_id from 12344 ~ 12399

    ustin thanks for the earlier help. Part of the requiremnt is met, now the tester can delete the rage of rows from 'dropbox', table. I am quiet not done in my second of the requirement. And that is pull the first 100 or 200 etc rows from the parent table (user_auth), and delete them from (dropbox). user_auth does not get affected. I able to user rank and dense_rank by create_time against user_auth table, and get the first 100 or 200 rows. However when join with dropbox, for example dropbox.user_id=user_auth.user_id. Query get hunged. I am not sure do i need to write a procedure for this, or a can be acieved by SQL. This is a test env.
    SQL> desc user_auth
    Name Null? Type
    USER_ID NOT NULL NUMBER(10)
    USER_NAME NOT NULL VARCHAR2(32)
    ACCOUNT_STATUS_CODE NOT NULL NUMBER(3)
    PASSWD VARCHAR2(13)
    DEVICE_ID_TYPE VARCHAR2(10)
    DEVICE_ID VARCHAR2(36)
    OLD_MSISDN NUMBER(15)
    MASTER_LOCK_CODE VARCHAR2(3)
    PARTNER_ID NOT NULL NUMBER(3)
    CREATE_TIME NUMBER(10)
    MAIL_PROVISIONED NOT NULL NUMBER(1)
    PASSWD_TYPE_ID NUMBER(3)
    USER_ID is primary key.
    INDEX_NAME INDEX_TYPE UNIQUENES
    PK_USER_AUTH_USER_ID NORMAL UNIQUE
    I_USER_AUTH_USER_NAME_PARTNER NORMAL UNIQUE
    I_USER_AUTH_DEVICE NORMAL UNIQUE
    I_USER_AUTH_MSISDN NORMAL UNIQUE
    DROPBOX
    Name Null? Type
    USER_ID NOT NULL NUMBER(10)
    DROPBOX_ID NUMBER(10)
    UPDATE_TIME NUMBER(10)
    MESSAGE_TYPE VARCHAR2(64)
    MESSAGE BLOB
    SURVIVE_REBOOT NUMBER(1)
    DELETE_TIME NOT NULL NUMBER(10)
    No Primary KEY
    INDEX_NAME INDEX_TYPE UNIQUENES
    I_DROPBOX_USER_ID NORMAL NONUNIQUE
    I_DROPBOX_SURVIVE_REBOOT NORMAL NONUNIQUE
    If I run
    select user_id, create_time, rnk1 FROM
    (select user_id, user_name, to_char(convert_unix_time(create_time)) create_time, DENSE_RANK() OVER (ORDER BY user_name) rnk1 from user_auth where user_name LIKE '%stomp%_%')
    where rnk1 < 100
    I get the result. How do i select these first 100 rows in the dropbox and delete them. relationship is many to many.

  • How does the CBO calculate the selectivity for range predicates on ROWID ?

    Hi all,
    I'm wondering how the CBO estimate the selectivity for range predicates based on ROWID columns.
    For example, for the following query the CBO estimates there's going to be 35004 rows returned instead of 7:
    SQL> SELECT count(*)
      FROM intsfi i
    WHERE
    ROWID>='AAADxyAAWAAHDLIAAB' AND ROWID<='AAADxyAAWAAHDLIAAH';  2    3    4
      COUNT(*)
             7
    Elapsed: 00:00:02.31
    SQL> select * from table(dbms_xplan.display_cursor(null,null,'iostats last'));
    PLAN_TABLE_OUTPUT
    SQL_ID  aqbdu2p2t6w0z, child number 1
    SELECT count(*)   FROM intsfi i  WHERE  ROWID>='AAADxyAAWAAHDLIAAB' AND
    ROWID<='AAADxyAAWAAHDLIAAH'
    Plan hash value: 1610739540
    | Id  | Operation             | Name    | Starts | E-Rows | A-Rows |   A-Time   | Buffers |
    |   0 | SELECT STATEMENT      |         |      1 |        |      1 |00:00:02.31 |   68351 |
    |   1 |  SORT AGGREGATE       |         |      1 |      1 |      1 |00:00:02.31 |   68351 |
    |*  2 |   INDEX FAST FULL SCAN| INTSFI2 |      1 |  35004 |      7 |00:00:02.31 |   68351 |
    Predicate Information (identified by operation id):
       2 - filter((ROWID>='AAADxyAAWAAHDLIAAB' AND ROWID<='AAADxyAAWAAHDLIAAH'))According to Jonathan Lewis' book, for a normal column the selectivity would have been:
    (value_column1-value_column2)/(high_value-low_value)+1/num_distinct+1/num_distinct
    But here with the ROWID column, how does the CBO make its computation ?
    SINGLE TABLE ACCESS PATH
      Single Table Cardinality Estimation for INTSFI[I]
      Table: INTSFI  Alias: I
        Card: Original: 14001681.000000  Rounded: 35004  Computed: 35004.20  Non Adjusted: 35004.20

    Hi Jonathan,
    Some Clarifications
    =============
    DELETE /*+ ROWID(I) */ FROM INTSFI I WHERE
    (I.DAVAL<=TO_DATE('12032008','DDMMYYYY') AND (EXISTS(SELECT 1 FROM
    INTSFI S WHERE S.COINT=I.COINT AND S.NUCPT=I.NUCPT AND S.CTSIT=I.CTSIT
    AND NVL(S.RGCID,-1)=NVL(I.RGCID,-1) AND S.CODEV=I.CODEV AND
    S.COMAR=I.COMAR AND S.DAVAL>I.DAVAL) AND I.COMAR IN (SELECT P.COMAR
    FROM PURMAR P WHERE P.NUPUR=1))) AND ROWID>='AAADxyAAWAAHDLIAAB' AND
    ROWID<='AAADxyAAWAAHDLIAAH'
    Plan hash value: 1677274993
    | Id  | Operation                      | Name    | Starts | E-Rows | A-Rows |   A-Time   | Buffers |  OMem |  1Mem | Used-Mem |
    |   0 | DELETE STATEMENT               |         |      1 |        |      0 |00:00:05.94 |   53247 |    |          |          |
    |   1 |  DELETE                        | INTSFI  |      1 |        |      0 |00:00:05.94 |   53247 |    |          |          |
    |*  2 |   HASH JOIN SEMI               |         |      1 |   9226 |      7 |00:00:05.94 |   53180 |   783K|   783K|  471K (0)|
    |   3 |    NESTED LOOPS                |         |      1 |   9226 |      7 |00:00:00.01 |      10 |    |          |          |
    |*  4 |     TABLE ACCESS BY ROWID RANGE| INTSFI  |      1 |   9226 |      7 |00:00:00.01 |       6 |    |          |          |
    |*  5 |     INDEX UNIQUE SCAN          | PURMAR1 |      7 |      1 |      7 |00:00:00.01 |       4 |    |          |          |
    |   6 |    INDEX FAST FULL SCAN        | INTSFI1 |      1 |     14M|   7543K|00:00:01.73 |   53170 |    |          |          |
    Predicate Information (identified by operation id):
       2 - access("S"."COINT"="I"."COINT" AND "S"."NUCPT"="I"."NUCPT" AND "S"."CTSIT"="I"."CTSIT" AND
                  NVL("S"."RGCID",(-1))=NVL("I"."RGCID",(-1)) AND "S"."CODEV"="I"."CODEV" AND "S"."COMAR"="I"."COMAR")
           filter("S"."DAVAL">"I"."DAVAL")
       4 - access(ROWID>='AAADxyAAWAAHDLIAAB' AND ROWID<='AAADxyAAWAAHDLIAAH')
           filter("I"."DAVAL"<=TO_DATE(' 2008-03-12 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))
       5 - access("P"."NUPUR"=1 AND "I"."COMAR"="P"."COMAR")
    When I force the NESTED LOOP SEMI JOIN the query runs faster:
    DELETE /*+ ROWID(I) */ FROM INTSFI I WHERE
    (I.DAVAL<=TO_DATE('12032008','DDMMYYYY') AND (EXISTS(SELECT /*+ NL_SJ
    */ 1 FROM INTSFI S WHERE S.COINT=I.COINT AND S.NUCPT=I.NUCPT AND
    S.CTSIT=I.CTSIT AND NVL(S.RGCID,-1)=NVL(I.RGCID,-1) AND S.CODEV=I.CODEV
    AND S.COMAR=I.COMAR AND S.DAVAL>I.DAVAL) AND I.COMAR IN (SELECT P.COMAR
    FROM PURMAR P WHERE P.NUPUR=1))) AND ROWID>='AAADxyAAWAAHDLIAAB' AND
    ROWID<='AAADxyAAWAAHDLIAAH'
    Plan hash value: 2031485112
    | Id  | Operation                      | Name    | Starts | E-Rows | A-Rows |   A-Time   | Buffers |
    |   0 | DELETE STATEMENT               |         |      1 |        |      0 |00:00:00.01 |      94 |
    |   1 |  DELETE                        | INTSFI  |      1 |        |      0 |00:00:00.01 |      94 |
    |   2 |   NESTED LOOPS SEMI            |         |      1 |   9226 |      7 |00:00:00.01 |      27 |
    |   3 |    NESTED LOOPS                |         |      1 |   9226 |      7 |00:00:00.01 |       9 |
    |*  4 |     TABLE ACCESS BY ROWID RANGE| INTSFI  |      1 |   9226 |      7 |00:00:00.01 |       5 |
    |*  5 |     INDEX UNIQUE SCAN          | PURMAR1 |      7 |      1 |      7 |00:00:00.01 |       4 |
    |*  6 |    INDEX RANGE SCAN            | INTSFI1 |      7 |     14M|      7 |00:00:00.01 |      18 |
    Predicate Information (identified by operation id):
       4 - access(ROWID>='AAADxyAAWAAHDLIAAB' AND ROWID<='AAADxyAAWAAHDLIAAH')
           filter("I"."DAVAL"<=TO_DATE(' 2008-03-12 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))
       5 - access("P"."NUPUR"=1 AND "I"."COMAR"="P"."COMAR")
       6 - access("S"."COINT"="I"."COINT" AND "S"."NUCPT"="I"."NUCPT" AND
                  "S"."CTSIT"="I"."CTSIT" AND "S"."CODEV"="I"."CODEV" AND "S"."COMAR"="I"."COMAR" AND
                  "S"."DAVAL">"I"."DAVAL")
           filter(NVL("S"."RGCID",(-1))=NVL("I"."RGCID",(-1)))the above post is from Ahmed AANGOUR
    Case 1 - . If you check Plan hash value: 16772749938
    =====
    TABLE ACCESS BY ROWID RANGE| INTSFI  For every row access from INTSFI - it fetches a record from INDEX UNIQUE SCAN | PURMAR1
    If we check A-rows = 9226
    9226 * 7 = 64582 request across the table - perhaps with hint of rowid it fetches exact rows from PURMAR1
    in this case i think going for hash join with ordered hints (jonathan as you suggest go for leading hint's instead of ordered) - from INTSFI - PURMAR1 - instead of going for IN clause would get the rows that satifies the ("P"."NUPUR"=1 AND "I"."COMAR"="P"."COMAR")
    |*  2 |   HASH JOIN SEMI               |         |      1 |   9226 |      7 |00:00:05.94 |   53180 |   783K|   783K|  471K (0)|
    |   3 |    NESTED LOOPS                |         |      1 |   9226 |      7 |00:00:00.01 |      10 |    |          |          |
    |*  4 |     TABLE ACCESS BY ROWID RANGE| INTSFI  |      1 |   9226 |      7 |00:00:00.01 |       6 |    |          |          |
    |*  5 |     INDEX UNIQUE SCAN          | PURMAR1 |      7 |      1 |      7 |00:00:00.01 |       4 |    |          |          |My understanding with above plan would change to
    HASH JOIN
    TABLE ACCESS BY ROWID RANGE| INTSFI
    INDEX UNIQUE SCAN | PURMAR1
    HASH JOIN
    INDEX FAST FULL SCAN | INTSFI1
    Which migt be feasible.
    2 .
    DELETE /*+ ROWID(I) */ FROM INTSFI I WHERE
    (I.DAVAL<=TO_DATE('12032008','DDMMYYYY') AND (EXISTS(SELECT /*+ NL_SJ
    */ 1 FROM INTSFI S WHERE S.COINT=I.COINT AND S.NUCPT=I.NUCPT AND
    S.CTSIT=I.CTSIT AND NVL(S.RGCID,-1)=NVL(I.RGCID,-1) AND S.CODEV=I.CODEV
    AND S.COMAR=I.COMAR AND S.DAVAL>I.DAVAL) AND I.COMAR IN (SELECT P.COMAR
    FROM PURMAR P WHERE P.NUPUR=1))) AND ROWID>='AAADxyAAWAAHDLIAAB' AND
    ROWID<='AAADxyAAWAAHDLIAAH'Ahmed AANGOUR, modified the query by /*+ NL_SJ */ hint, Instead of that in to remove the most of the rows as we join the tables using subquery, I still doubt it
    to go push_predicate hints - still doubt it.
    Jonathan your comments are most valuable in the above two cases..
    Looking forward to calrify my understanding with concepts of indexes for above test cases
    - Pavan Kumar N

  • How to select data from 3rd row of Excel to insert into Sql server table using ssis

    Hi,
    Iam having Excel files with headers in first two rows , i want two skip that two rows and select data from 3rd row to insert into Sql Server table using ssis.3rd row is having column names.

                                                         CUSTOMER DETAILS
                         REGION
    COL1        COL2        COL3       COL4           COL5          COL6          COL7
           COL8          COL9          COL10            COL11      
    1            XXX            yyyy         zzzz
    2            XXX            yyyy        zzzzz
    3           XXX            yyyy          zzzzz
    4          XXX             yyyy          zzzzz
    First two rows having cells merged and with headings in excel , i want two skip the first two rows and select the data from 3rd row and insert into sql server using ssis
    Set range within Excel command as per below
    See
    http://www.joellipman.com/articles/microsoft/sql-server/ssis/646-ssis-skip-rows-in-excel-source-file.html
    Please Mark This As Answer if it solved your issue
    Please Mark This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Range and rows

    Hi folks,
    I never used range or rows before in analytic functions. I took some time to learn a bit about them but cant figure out why would you need to use it? Most of the things I needed I got from lead or lag functions. So whats the deal with window functions? Where are they useful?
    Best regards,
    Igor

    Hi, Igor,
    Igor S. wrote:
    Hi folks,
    I never used range or rows before in analytic functions. I took some time to learn a bit about them but cant figure out why would you need to use it? Most of the things I needed I got from lead or lag functions. So whats the deal with window functions? Where are they useful?What do you mean by "window function"?
    That term most commonly refers to functions that allow you to specify a window of consecutive rows in your data set, and the function will operate on the rows within that window. In that sense, most analytic functions are window functions.
    The default window is RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW. You only need to specify a windowing clause (that is, RANGE or ROWS) if you want to override that.
    For example, the following query shows the average salary from the scott.emp table, and the number of salaries that contribute to that average, two different ways. The columns cnt_sal and avg_sal use the default windowing, so the figures on each row include that row itself, and all earlier rows (where hiredate determines what is earlier). The columns cnt_60 and avg_60 include only the 60 days up to, but not including, the row itself. Notice that sometimes there are 0 rows in that window.
    SELECT       ename
    ,       hiredate
    ,       sal
    ,       COUNT (sal) OVER ( ORDER BY  hiredate )     AS cnt_sal
    ,       AVG (sal)   OVER ( ORDER BY  hiredate     )     AS avg_sal  
    ,       COUNT (sal) OVER ( ORDER BY  hiredate
                                RANGE BETWEEN  61 PRECEDING
                                AND          1 PRECEDING
                         )                    AS cnt_sal_60
    ,       AVG (sal)   OVER ( ORDER BY  hiredate
                                RANGE BETWEEN  61 PRECEDING
                                AND          1 PRECEDING
                         )                    AS avg_sal_60
    FROM      scott.emp
    ORDER BY  hiredate
    ;Notice that the formula for cnt_sal is exactly the same as the formula for cnt_sal, except that cnt_sal_60 specifies a RANGE. The same goes for avg_sal and avg_sal_60.
    Output:
    ENAME      HIREDATE         SAL    CNT_SAL    AVG_SAL CNT_SAL_60 AVG_SAL_60
    SMITH      17-DEC-80        800          1        800          0
    ALLEN      20-FEB-81       1600          2       1200          0
    WARD       22-FEB-81       1250          3 1216.66667          1       1600
    JONES      02-APR-81       2975          4    1656.25          2       1425
    BLAKE      01-MAY-81       2850          5       1895          1       2975
    CLARK      09-JUN-81       2450          6     1987.5          1       2850
    TURNER     08-SEP-81       1500          7 1917.85714          0
    MARTIN     28-SEP-81       1250          8   1834.375          1       1500
    KING       17-NOV-81       5000          9 2186.11111          1       1250
    JAMES      03-DEC-81        950         11 2147.72727          1       5000
    FORD       03-DEC-81       3000         11 2147.72727          1       5000
    MILLER     23-JAN-82       1300         12 2077.08333          2       1975
    SCOTT      19-APR-87       3000         13 2148.07692          0
    ADAMS      23-MAY-87       1100         14 2073.21429          1       3000Edited by: Frank Kulash on Apr 3, 2013 9:16 AM
    Added example from scott.emp

  • VBA crashes on "rowNum = objXLAppln.Range("A" & Rows.Count).End(xlUp).Row"

    I have code that has the line "rowNum = objXLAppln.Range("A" & Rows.Count).End(xlUp).Row". Every once in a while the macro crashes on this line. It doesn't happen regularly or with a pattern. The entire code is below. I have several
    modules that use this line of code. Any ideas?
    Function ImportScores()
    Dim RecSet As DAO.Recordset
    Dim objXLAppln As Excel.Application
    Dim objWBook As Excel.Workbook
    Dim rowNum As Variant
    Dim i As Integer
    Dim j As Integer
    Dim StrPathFile As String, strFile As String, strPath As String
    Dim strBrowseMsg As String, strInitialDirectory As String, strFilter As String
    'show dialogue box
    strBrowseMsg = "Select the EXCEL file:"
    'set directory to load files from
    strInitialDirectory = "C:\Bridge_CIP_Part-A_B\"
    'run strFilter function
    strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.xlsx)", "*.xlsx")
    StrPathFile = ahtCommonFileOpenSave(InitialDir:=strInitialDirectory, _
    Filter:=strFilter, OpenFile:=True, _
    DialogTitle:=strBrowseMsg, _
    Flags:=ahtOFN_HIDEREADONLY)
    If StrPathFile = "" Then
    MsgBox "No file was selected.", vbOK, "No Selection"
    Exit Function
    End If
    'Set Excel application object. Critical for macro to run properly. Do not change.
    Set objXLAppln = New Excel.Application
    'Open workbook and worksheet to load data.
    With objXLAppln
    Set objWBook = .Workbooks.Open(StrPathFile)
    objXLAppln.Visible = True
    End With
    Set RecSet = CurrentDb.OpenRecordset("Performance_Scores")
    'Copy data from Excel cells to Access fields
    objXLAppln.Sheets("Performance_Attributes").Select
    rowNum = objXLAppln.Range("A" & Rows.Count).End(xlUp).Row
    objXLAppln.Range("A10").Select
    'Add records to table from Excel
    With RecSet
    For i = 0 To rowNum - 9
    RecSet.AddNew
    RecSet.Fields("CIP_ID").value = objXLAppln.ActiveCell.Offset(i, 0).value
    RecSet.Fields("5YearScore").value = objXLAppln.ActiveCell.Offset(i, 53).value
    RecSet.Fields("10YearScore").value = objXLAppln.ActiveCell.Offset(i, 54).value
    RecSet.Fields("15YearScore").value = objXLAppln.ActiveCell.Offset(i, 55).value
    RecSet.Fields("20YearScore").value = objXLAppln.ActiveCell.Offset(i, 56).value
    RecSet.Update
    Next i
    End With
    'Close everything
    RecSet.Close
    objWBook.Close SaveChanges:=False
    objXLAppln.Quit
    Set RecSet = Nothing
    Set objWBook = Nothing
    Set objXLAppln = Nothing
    End Function

    I rewrote as below.
    But rather than doing it this way, I would create a linked table to this workbook and import the data using an Append query.
    Function ImportScores()
        Const FOOTER_ROWS_TO_SKIP As Integer = 10
        Const COL_CIP_ID As Integer = 1
        Const COL_5YEARSCORE As Integer = 54
        Dim RecSet      As DAO.Recordset
        Dim objXLAppln  As Excel.Application
        Dim objWBook    As Excel.Workbook
        Dim objXLSheet  As Excel.Worksheet
        Dim rowNum      As Variant
        Dim row         As Integer
        Dim j           As Integer
        Dim StrPathFile As String, strFile As String, strPath As String
        Dim strBrowseMsg As String, strInitialDirectory As String, strFilter As String
        'show dialogue box
        strBrowseMsg = "Select the EXCEL file:"
        'set directory to load files from
        strInitialDirectory = "C:\Bridge_CIP_Part-A_B\"
        'run strFilter function
        strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.xlsx)", "*.xlsx")
        StrPathFile = ahtCommonFileOpenSave(InitialDir:=strInitialDirectory, _
                                            Filter:=strFilter, OpenFile:=True,
                                            DialogTitle:=strBrowseMsg,
                                            Flags:=ahtOFN_HIDEREADONLY)
        'StrPathFile = "C:\Users\Tom\Documents\test.xlsx"        'testonly
        If StrPathFile = "" Then
            MsgBox "No file was selected.", vbOK, "No Selection"
            Exit Function
        End If
        'Set Excel application object. Critical for macro to run properly. Do not change.
        Set objXLAppln = New Excel.Application
        'Open workbook and worksheet to load data.
        With objXLAppln
            Set objWBook = .Workbooks.Open(StrPathFile)
            objXLAppln.Visible = True
            Set objXLSheet = objXLAppln.Sheets("Performance_Scores")
        End With
        rowNum = objXLSheet.UsedRange.Rows.Count
        'Add records to table from Excel
        Set RecSet = CurrentDb.OpenRecordset("Performance_Scores", dbOpenDynaset)
        With RecSet
            For row = 1 To rowNum - FOOTER_ROWS_TO_SKIP
                RecSet.AddNew
                RecSet.Fields("CIP_ID").Value = objXLSheet.Cells(row, COL_CIP_ID).Value
                RecSet.Fields("5YearScore").Value = objXLSheet.Cells(row, COL_5YEARSCORE).Value
                'etc.
                RecSet.Update
            Next row
        End With
        'Close everything
        RecSet.Close
        objWBook.Close SaveChanges:=False
        objXLAppln.Quit
        Set RecSet = Nothing
        Set objWBook = Nothing
        Set objXLAppln = Nothing
    End Function
    -Tom. Microsoft Access MVP

  • Display range of rows

    Can anyone suggest me an efficent SQL which can return range of rows for example I want to display records with rownum>=20 and rownum<=40.

    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Uma Santharam:
    Can anyone suggest me an efficent SQL which can return range of rows for example I want to display records with rownum>=20 and rownum<=40. <HR></BLOCKQUOTE>
    Hi,
    You can not use equal to and greater then condition in rownum.
    Secondly if you want 20 and 40 to be included in range search then use rownum <21
    and rownum < 41.
    Try to use following query to solve your above said problem.
    select e1.empno from emp e1
    where rownum <10 and empno not in
    ( select e1.empno from emp e1 where rownum <5);
    null

  • JTable checkboxes doesn't retain their selection when a new row is added!!

    HI,
    My gui has the JTable component which has 5 columns. out of which 4 columns are checkboxes. whenever i select an item from the Jlist and click on the add button it will add a new row in JTable.
    but the problem is whenever a new row is added to the table. the previously selected checkboxes of previous rows are being deselected. But i want to retain the selection of my previous rows even when a new row is added. please help me how to achieve this..i am posting my JTable code here:
    class FunctionTableModel extends AbstractTableModel{
           /** The instances who's attribute structure we are reporting */
        //protected InitModel m_init;
        protected String func_element;
        protected int counter;
        //protected String[] func_array;
        protected Vector func_vector;
        /** The flag for whether the instance will be included */
        protected boolean [] m_Sum;
        protected boolean [] m_Min;
        protected boolean [] m_Avg;
        protected boolean [] m_Max;
        protected boolean [] m_SD;
         * Creates the tablemodel with the given set of instances.
         * @param instances the initial set of Instances
        public FunctionTableModel() {
          counter =0;
             func_vector = new Vector();
         public FunctionTableModel(Vector vec) {
            func_vector = vec;
        public Vector getDataVector(){
            return func_vector;
         * Sets the tablemodel to look at a new set of instances.
         * @param instances the new set of Instances.
        public void setElement(Vector vec) {
               for(int i=0;i<vec.size();i++){
            func_vector.add(vec.elementAt(i));
            counter++;
          fireTableDataChanged();   
          m_Sum = new boolean [counter];
          m_Min = new boolean[counter];
          m_Avg = new boolean[counter];
          m_Max = new boolean[counter];
          m_SD = new boolean[counter];
         * Gets the number of attributes.
         * @return the number of attributes.
        public int getRowCount() {
               return func_vector.size();
         * Gets the number of columns: 3
         * @return 3
        public int getColumnCount() {
          return 6;
         * Gets a table cell
         * @param row the row index
         * @param column the column index
         * @return the value at row, column
        public Object getValueAt(int row, int column) {
          switch (column) {
          case 0:
            return func_vector.elementAt(row);
          case 1:
            return new Boolean(m_Sum[row]);
          case 2:
            return new Boolean(m_Min[row]);
          case 3:
            return new Boolean(m_Avg[row]);
          case 4:
            return new Boolean(m_Max[row]);
          case 5:
            return new Boolean(m_SD[row]); 
          default:
            return null;
        public void removeAll(){
            func_vector.removeAllElements();
            fireTableDataChanged();
         * Gets the name for a column.
         * @param column the column index.
         * @return the name of the column.
        public String getColumnName(int column) {
          switch (column) {
          case 0:
            return new String("Function Selected");
          case 1:
            return new String("Sum");
          case 2:
            return new String("Min");
          case 3:
            return new String("Avg");
          case 4:
            return new String("Max");
          case 5:
            return new String("SD");   
          default:
         return null;
         * Sets the value at a cell.
         * @param value the new value.
         * @param row the row index.
         * @param col the column index.
        public void setValueAt(Object value, int row, int col) {
          if(col == 0){
            counter++;
            func_vector.add(counter,value.toString());
          if (col == 1)
            m_Sum[row] = ((Boolean) value).booleanValue();
          if (col == 2)
            m_Min[row] = ((Boolean) value).booleanValue();
          if (col == 3)
            m_Avg[row] = ((Boolean) value).booleanValue();
          if (col == 4)
            m_Max[row] = ((Boolean) value).booleanValue();
          if (col == 5)
            m_SD[row] = ((Boolean) value).booleanValue();       
         * Gets the class of elements in a column.
         * @param col the column index.
         * @return the class of elements in the column.
        public Class getColumnClass(int col) {
             return getValueAt(0, col).getClass();
         * Returns true if the column is the "selected" column.
         * @param row ignored
         * @param col the column index.
         * @return true if col == 1.
        public boolean isCellEditable(int row, int col) {
          if (col >= 1) {
             return true;
          return false;
        public void removeRow(int row){
            if(row<=func_vector.size()){
                          func_vector.removeElementAt(row);
                counter--;
            fireTableDataChanged();
        }

    hi parvathi,
    i have made changes to my previous code and here's the code:
      class FunctionTableModel extends DefaultTableModel{
           /** The instances who's attribute structure we are reporting */
        //protected InitModel m_init;
        protected String func_element;
        protected int counter;
        protected int counter1;
        //protected String[] func_array;
        protected Vector func_vector;
        /** The flag for whether the instance will be included */
        protected boolean [] m_Sum;
        protected boolean [] m_Min;
        protected boolean [] m_Avg;
        protected boolean [] m_Max;
        protected boolean [] m_SD;
        //protected Vector m_Sum1;
        //protected Vector m_Min1;
        //protected Vector m_Avg1;
        //protected Vector m_Max1;
        //protected Vector m_SD1;
         * Creates the tablemodel with the given set of instances.
         * @param instances the initial set of Instances
        public FunctionTableModel() {
            System.out.println("entered the constr");
          counter =0;
          //counter1=0;
          //m_Sum1 = new Vector();
          //m_Min1 = new Vector();
          //m_Avg1 = new Vector();
          //m_Max1 = new Vector();
          //m_SD1 = new Vector();
          //func_array = new String[];
          func_vector = new Vector();
         public FunctionTableModel(Vector vec) {
            func_vector = vec;
            //setElement(func_vector);
        public Vector getDataVector(){
            return func_vector;
         * Sets the tablemodel to look at a new set of instances.
         * @param instances the new set of Instances.
        public void addRow(Vector vec) {
          //counter++; 
          //func_element = ele;
          //System.out.println("FunctionTableModel- setElement() method");
          for(int i=0;i<vec.size();i++){
            func_vector.add(vec.elementAt(i));
            counter++;  
           //System.out.println("counter ="+counter+new boolean[counter]); 
            //m_Sum1 = m_Sum;
            //m_Min1 = m_Min;
            //m_Avg1 = m_Avg;
            //m_Max1 = m_Max;
            //m_SD1 = m_SD;
            //m_Sum = new boolean[counter];
            //System.out.println("at setElement");
            m_Sum = new boolean[counter];
            //System.out.println(counter);
            m_Min = new boolean[counter];
            //m_Min;
            m_Avg = new boolean[counter];
            //m_Avg1 = m_Avg;
            m_Max = new boolean[counter];
            //m_Max1 = m_Max;
            m_SD = new boolean[counter];
            //m_SD1 = m_SD;
            //counter1++;
          //func_array[counter]=ele;
          //func_vector.add(counter,ele);
          fireTableDataChanged();  
         * Gets the number of attributes.
         * @return the number of attributes.
        //public int getRowCount() {
          //System.out.println("FunctionTableModel- getRowCount() method");
          //return func_vector.size();
         * Gets the number of columns: 3
         * @return 3
        public int getColumnCount() {
          return 6;
         * Gets a table cell
         * @param row the row index
         * @param column the column index
         * @return the value at row, column
        public Object getValueAt(int row, int column) {
          switch (column) {
          case 0:
            return func_vector.elementAt(row);
          case 1:{
            //System.out.println("in case 1");
            //Boolean m_Sum_Value = new Boolean(m_Sum[row]);
            //System.out.println("m_Sum_Value:"+m_Sum_Value.booleanValue());
            return new Boolean(m_Sum[row]);
            //m_Sum1.add(m_Sum_Value);
            //return m_Sum_Value;
          case 2:
            return new Boolean(m_Min[row]);
          case 3:
            return new Boolean(m_Avg[row]);
          case 4:
            return new Boolean(m_Max[row]);
          case 5:
            return new Boolean(m_SD[row]); 
          default:
            return null;
        public void removeAll(){
            func_vector.removeAllElements();
            //m_Sum1.removeAllElements();
            fireTableDataChanged();
         * Gets the name for a column.
         * @param column the column index.
         * @return the name of the column.
        public String getColumnName(int column) {
          switch (column) {
          case 0:
            return new String("Function Selected");
          case 1:
            return new String("Sum");
          case 2:
            return new String("Min");
          case 3:
            return new String("Avg");
          case 4:
            return new String("Max");
          case 5:
            return new String("SD");   
          default:
         return null;
         * Sets the value at a cell.
         * @param value the new value.
         * @param row the row index.
         * @param col the column index.
        public void setValueAt(Object value, int row, int col) {
          if(col == 0){
            counter++;
            func_vector.add(counter,value.toString());
          if (col == 1) {
            m_Sum[row] = ((Boolean) value).booleanValue();
            //System.out.println("m_Sum length "+m_Sum.length);
            //for(int i=0;i<=row;i++)
            //    System.out.println("m_Sum1 "+i+((Boolean)m_Sum1.elementAt(i)).booleanValue());
            //System.out.println("m_Sum1["+row+"] "+ ((Boolean)m_Sum1.elementAt(row)).booleanValue());
            //    System.out.println("m_Sum["+i+"] "+ m_Sum);
    if (col == 2)
    m_Min[row] = ((Boolean) value).booleanValue();
    if (col == 3)
    m_Avg[row] = ((Boolean) value).booleanValue();
    if (col == 4)
    m_Max[row] = ((Boolean) value).booleanValue();
    if (col == 5)
    m_SD[row] = ((Boolean) value).booleanValue();
    * Gets the class of elements in a column.
    * @param col the column index.
    * @return the class of elements in the column.
    public Class getColumnClass(int col) {
    return getValueAt(0, col).getClass();
    * Returns true if the column is the "selected" column.
    * @param row ignored
    * @param col the column index.
    * @return true if col == 1.
    public boolean isCellEditable(int row, int col) {
    if (col >= 1) {
         return true;
    return false;
    public void removeRow(int row){
    if(row<=func_vector.size()){
    func_vector.removeElementAt(row);
    counter--;
    fireTableDataChanged();
    previouslu i was using the setElement method. now i have replaced with the addRow method...
    but anyways...the control is not going to any of these overridden methods...and none of the elements are added to the table. But i comment of all the addRow, getValueAt, getColumnClass methods...then it's adding rows to the table but with only the first column all the remaiing columns are just empty...
    i am fed up with this...if you observe i have commented out somany lines...becoz i am trying to save my boolean array values into a vector..but that was also in vain...
    i appreciate for ur help...
    thanks
    sri

  • Select- Color Range- Results in Blue Screen (PC)  (driver out of date)

    I've been using the CS6 beta about two days.  While experimenting with color range I experienced two consecutive blue screen crashes.  The first time it happened,I was working with the color range selector and was replacing the selected areas with another color using the paint bucket.  About the third time I attempted this, my PC blue screened.  The second time, I opened a photo, went to Select>Color Range and got an immediate blue screen crash.
    I then went back to CS5 and I've been playing with the same scenario with no apparent problems.
    My PC is a store built computer.  It consists of an MSI 990-FXA GD80 motherboard, an AMD Phenom 1100t CPU, Asus GTX550 Ti graphics card and 8 gig of RAM.  It boots from a 60 gig SSD and my programs reside on a 500 gig hard drive.  The OS is Windows 7 Professional 64 bit.  CS6 is using the hard drive for its scratch disk and Photoshop is using 4339 mb of the 7232 mb of available RAM - I haven't changed that.  I'm running CS6 as administrator because the way it installed, it would only run in that fashion.
    One disappointment during the installation was CS6 made no attempt to read my preferences from the CS5 install.  That may be covered in another post, I've not yet looked.
    Please keep us informed as new betas are released, because I would like some time to work with this puppy before plunking down big bux for the upgrade.  As it is now, I'm going back to CS5.  I get mighty nervous when my super computer blue screens!
    Gerry
    gswetsky AT bellsouth DOT net

    The GPU is often at root of issues like yours. I've had so many problems with Nvidia drivers for their gaming-oriented adapters (like yours) that I finally went with one of their workstation cards. I have a Quadro card with just enough RAM to make Photoshop happy. The workstation drivers are optimized for reliability, the consumer card drivers are optimized for gaming and that often means they're less stable and reliable with Photoshop.

  • Devolped an ALV report for daily cash receipts for selected date range

    hi,   
                 how to devlop an ALV report for daily cash receipts for selected date range.for this report what are the tables and fields we have to use.what is the selectionscreen&what is logic.give me sample report.

    hi,   
                 how to devlop an ALV report for daily cash receipts for selected date range.for this report what are the tables and fields we have to use.what is the selectionscreen&what is logic.give me sample report.

  • Devloped an ALV report for daily cash receipts for selected date range

    hi,   
                 how to devlop an ALV report for daily cash receipts for selected date range.for this report what are the tables and fields we have to use.what is the selectionscreen&what is logic.give me sample report.

    Hi,
    You can develop simple reports using Report Painter.
    You may be also interested in:
    Check report SAPMF05A for credit memo
    See the following Std reports on Payment Advices execute the Tcodes:
    S_ALR_87009888
    S_ALR_87009889
    S_ALR_87009890
    S_ALR_87009891
    S_ALR_87009892
    S_ALR_87009893
    S_ALR_87009978
    S_ALR_87009979
    S_ALR_87009980
    S_ALR_87009981
    S_ALR_87009982
    S_ALR_87009983
    S_ALR_87010056
    S_ALR_87010057
    S_ALR_87010058
    S_ALR_87010059
    S_ALR_87010060
    S_ALR_87010061
    S_ALR_87010066
    S_ALR_87010067
    S_ALR_87012106
    S_ALR_87012107
    S_ALR_87012108
    S_ALR_87012109
    S_ALR_87012110
    S_ALR_87012111
    S_ALR_87012116
    S_ALR_87012117
    S_ALR_87012200
    S_ALR_87012201
    S_ALR_87012202
    S_ALR_870122
    S_ALR_87012204
    S_ALR_87012205
    S_ALR_87012350
    S_ALR_87012351
    S_ALR_87012352
    S_ALR_87012353
    S_ALR_87012354
    S_ALR_87012355
    sample ALV report:
    tables:
    marav. "Table MARA and table MAKT
    Data to be displayed in ALV
    Using the following syntax, REUSE_ALV_FIELDCATALOG_MERGE can auto-
    matically determine the fieldstructure from this source program
    Data:
    begin of imat occurs 100,
    matnr like marav-matnr, "Material number
    maktx like marav-maktx, "Material short text
    matkl like marav-matkl, "Material group (so you can test to make
                            " intermediate sums)
    ntgew like marav-ntgew, "Net weight, numeric field (so you can test to
                            "make sums)
    gewei like marav-gewei, "weight unit (just to be complete)
    end of imat.
    Other data needed
    field to store report name
    data i_repid like sy-repid.
    field to check table length
    data i_lines like sy-tabix.
    Data for ALV display
    TYPE-POOLS: SLIS.
    data int_fcat type SLIS_T_FIELDCAT_ALV.
    select-options:
    s_matnr for marav-matnr matchcode object MAT1.
    start-of-selection.
    read data into table imat
      select * from marav
      into corresponding fields of table imat
      where
      matnr in s_matnr.
    end-of-selection.
    Now, we start with ALV
    To use ALV, we need a DDIC-structure or a thing called Fieldcatalogue.
    The fieldcatalouge can be generated by FUNCTION
    'REUSE_ALV_FIELDCATALOG_MERGE' from an internal table from any
    report source, including this report.
    The only problem one might have is that the report and table names
    need to be in capital letters. (I had it )
    Store report name
    i_repid = sy-repid.
    Create Fieldcatalogue from internal table
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
           EXPORTING
                I_PROGRAM_NAME         = sy-repid
                I_INTERNAL_TABNAME     = 'IMAT'  "capital letters!
                I_INCLNAME             = sy-repid
           CHANGING
                CT_FIELDCAT            = int_fcat
           EXCEPTIONS
                INCONSISTENT_INTERFACE = 1
                PROGRAM_ERROR          = 2
                OTHERS                 = 3.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                I_CALLBACK_PROGRAM       = i_repid
                I_STRUCTURE_NAME         = 'marav'
                I_DEFAULT                = 'X'
                I_SAVE                   = 'A'
           TABLES
                T_OUTTAB                 = imat.
      IF SY-SUBRC <> 0.
        WRITE: 'SY-SUBRC: ', SY-SUBRC .
      ENDIF.
    Hope this will help.
    Regards,
    Naveen.

Maybe you are looking for

  • How can I share cache files between users in a sandboxed Mac app?

    Our app downloads media files and stores them for use later. The size can be up to a few GB so it's considerable. Because this can be so large I want the cache to be shared across different users. My understanding of sandboxing is that you cannot wri

  • RE: (forte-users) Forte ADE

    In addition to this confusion, I'd like to see some statement by Forte to indicate WHEN the next Forte R4 is scheduled (before the Sun era is was said to be Summer 2000) and WHAT exactly it will contain (major headings will do). With the cancellation

  • I have doubt in pp module....

    i have doubt in pp module.... i want to know relationship between pp tables (s901,s902,s903,s904) and bomtables (mast,stpo,stko,stas) because the material(element) available in pp tables is not exists in bom tables. key: plant,material,sub material i

  • Shuts down when I save any file big or small

    I have Adobe CS5 and run it on a MacBookPro and recently AI started shutting down when I try to save a file. I tried to create a small mock file to save and it did the same thing. SO no matter the size of the file it just shuts down. I also restarted

  • What will be exact command instead of (archivelog from time 'SYSDATE-3';)

    HI all; rman configuration CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 14 DAYS and others is default i am taking weekly archivelog backup by following script run backup as compressed backupset device type disk tag "weekly_archivelog" format '/sw