Retrieving records at a single fetch !!!

Hi All. there is a big qns in my mind. Let me explain the problem first. I want to retrieve some 1000 records from the database but want to show 10 records per page. while clicking next or somthing the 2nd page i want show 10 records. Is this case, the transaction goes to the database and come back with the required records. For every time database interation is there and takes some time. If i want to fetch all the 1000 records in a single fetch and show it 10 by 10 means how to do that. Where i've to store the fetched records ? Could anyone please provide me a good solution for this. If possible with some sample codes too. Thankx in Advance.
Siva

Hi,
Thanks for ur response. In the case of
ase of retrieving all the records from the database
which i don't know how many records(no of rows and
cols not known) are in the table. How to proceed with
this? And one imp thing, after fetching this many
records where this gets stored? Awaiting for ur reply.The ArrayList rows will contain one entry per row retrieved from the database. Each entry in rows will be an ArrayList as well, where each element is the content of the respective column from your query.
The ArrayList rows will grow dynamically. The number specified in the constructor is only the initial size. Read up the docs for ArrayList.
The number of columns can be retrieved from the ResultSetMetaData object. Read the documentation about ResultSet and ResultSetMetaData
When displaying this page by page, you just need to iterate over rows and display the approriate number of entries from there.
Thomas

Similar Messages

  • Fetch out of Sequence error isn't returned when doing a single fetch

    Hi all,
    As per my understanding, if we fetch all the rows from a sys_refcursor into a collection, within the pl/sql block, then it doesn't return any row to the calling program. Instead a fetch out of sequence error is encountered. This worked well. However, when I use a single fetch statement(in case the sys_refcursor contains a single row), I do not encounter "Fetch Out Of Sequence" error. It would be really helpful if anyone could please explain this behaviour.
    Below is a sample code snippet that I ran in PL/SQL Developer:
    CREATE OR REPLACE PROCEDURE test_cur_1(in_dept_id VARCHAR2,
    out_cursor OUT SYS_REFCURSOR) IS
    temp_count NUMBER;
    temp_rec dept%ROWTYPE;
    BEGIN
    --This piece of code runs into a "Fetch Out Of Sequence" error, when trying to open up the sys_refcursor.
    OPEN out_cursor FOR
    SELECT *
    FROM dept
    WHERE dept_id = in_dept_id;--dept_id is the primary key
    LOOP
    EXIT WHEN out_cursor%NOTFOUND;
    FETCH out_cursor
    INTO temp_rec;
    dbms_output.put_line('department name: '||temp_rec.dept_name);
    END LOOP;
    EXCEPTION
    WHEN OTHERS THEN
    OPEN out_cursor FOR
    SELECT SQLCODE||'->'||SQLERRM FROM dual;
    END;
    CREATE OR REPLACE PROCEDURE test_cur_2(in_dept_id VARCHAR2,
    out_cursor OUT SYS_REFCURSOR) IS
    temp_count NUMBER;
    temp_rec dept%ROWTYPE;
    BEGIN
    --This piece of code does not run into a "Fetch Out Of Sequence" error. Instead the output sys_refcursor opens up for no rows to display.
    OPEN out_cursor FOR
    SELECT *
    FROM dept
    WHERE dept_id = in_dept_id;--dept_id is the primary key
    FETCH out_cursor
    INTO temp_rec;
    dbms_output.put_line('department name: '||temp_rec.dept_name);
    EXCEPTION
    WHEN OTHERS THEN
    OPEN out_cursor FOR
    SELECT SQLCODE||'->'||SQLERRM FROM dual;
    END;
    Appreciate all your time!

    When you loop through a cursor, Oracle does not know how many rows there will be in the cursor until it has fetched them all, and it cannot know it has fetched them all until it does one last fetch after getting the last row to find that ti gets nothing back. In psuedo code the fetch command works something like:
    open cursor
    cursor%notfound := null;
    -- This is the fetch phase
    ask sql engine to give me a row
    if I got one then
       cursor%notfound := false;
       populate variables/record with values
    else
       cursor%notfound := true;
    end if;
    -- end fetch phase
    go onto next command in the pl/sql blockSo, in your first procedure you fetch the last row of the cursor then go back to the top of the loop. Since Oracle does not know at this point that the last row has already been fetched so, out_cursor%notfound is still false, so it does another fetch at which point it now "knows" that the last row is fetched so notfound becomes true and your loop exits, returning control to the caller. At this point, presumably the caller attempts to fetch from the cursor. Since the cursor handle is already pointing past the last row you get the fetch out of sequence.
    In your second procedure, you fetch a single row from the cursor. You know that the cursor is pointing at the "last" row since you are querying based on the PK, but Oracle does not know that yet. You now return that cursor to the caller who does one more fetch which moves the pointer past the end of the cursor. The caller "sees" no rows, but that is because your procedure already fetched the rows, but did not "check" for the last row.
    John

  • Combining 2 records in a single cube

    Hi Everyone,
    I would like to get your opinion about this particular requirement.
    I have an opportunities cube (CRM) which stores info about different opportunities. One customer may go from one opportunity to another. Both the opportunities are saved as different records in BW for instance Oppt A (Record 1)and Oppt B (Record 2)
    So now client wants to see in a single record, which customer went from Oppt A to Oppt B.
    I am thinking about creating another cube and write a routine to check the Bill Account ( which is the only field available linking the 2 opportunities.
    Is this possible? Has anyone encountered or made such a routine?
    have you got other ways of doing this?
    Your inputs will be greatly appreciated.
    Thanks
    Kumar.

    Hi Vamsi,
    Thanks for your offer to help with the coding. That wont be necessary anymore as I figured out I will not be able to join the 2 records since there is a One to Many relationship between Oppt A and Oppt B. I will just display them as different records and sort them together.
    But since we have this idea of combining 2 records of a single cube, why don't we continue and close this.
    If there was a 1 to 1 Rel, the records would have shown this way
    Oppt A
    Bill Account
    Meter ID
    Transaction no
    Customer Name
    Address
    AutoDR Flag (Checked)
    Load Approved
    Oppt B
    Bill Account
    Meter ID
    Transaction no
    Customer Name
    Address
    TI Indicator Flag (Checked)
    Campaign Enrolled
    The Key fields would have been Bill Account and Meter ID
    So the final Oppt would have been ...
    Bill Account
    Meter ID
    Transaction no
    Customer Name
    Address
    AutoDR Flag (Checked)
    Load Approved
    TI Indicator Flag (Checked)
    Campaign Enrolled

  • Concatenate multiple records into one single record

    Hello everyone,
    Can anyone guide me how to merge multiple records into one single record
    like......... I am getting the data in the file like
    aaaaa/bbbbbbb/ccccccccccc/dddddddddddd/eee
    ffffff/gggg/hhhhhhhhhhhhhh
    /123/4567/55555/99999999/kaoabfa/eee
    fffff/kkkkkkkk/llllllllllllllllllllllll
    when i use gui_upload I am getting the data into the internal table in the above format.
    My main intension is to split the record at / to multiple lines and dowload it into another file.
    What i am planning to do is... if the line does not start with / then i want to concatenate the multiple lines into single line and then split it into multiple records. Can anyone guide me how to achieve this.

    Yes, it should work.
    In my example
    Loop at itab.
    concatenate i_text itab into i_text.
    endloop.
    You change that loop for the loop of your internal table with the file records
    So if you have this three records
    'aaaa/bbb/ccc'
    '/dddd/efg'
    'hijk/lmn'
    i_text will look like this at the end
    'aaaa/bbb/ccc/dddd/efghijk/lmn'
    then in this part of the code
    split i_text at '/' into table itab2.
    itab2 will have the records looking like this
    aaaa
    bbb
    ccc
    dddd
    efghijk
    lmn'

  • MessageTransformBean - SimplePlain2XML - Multiple records on a single line

    Hi,
    I am trying to convert multiple record from a single line to multipe rows in an XML message with the MessageTransformBean.
    If the record look like this it's working:
    RECORD1textETC
    RECORD2textETC
    But the incoming message are all on a single line:
    RECORD1textETCRECORD2textETC
    Is there a way to add a linefeed to my incoming message after X characters, or to tell the adapter to split by length instead of spliting on the end of line?
    Thanks,
    Martin

    I had to code a custom Module Adapter to do it.
    Here's the main part of the module adapter EOLConvertBean...
    Message msg = (Message) inputModuleData.getPrincipalData();
    XMLPayload xmlpayload = msg.getDocument();
    byte[] content = xmlpayload.getContent();
    byte crlf = 0x0A; // end of line char
    int current = 0;  // current bytes read     
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    int lines = content.length / recordLen; // record len = insert EOL after X recordLen
    // TODO change for do while for 1x line record
    for (int i = 0; i <= lines; i++) {
         baos.write(content, current, recordLen);
         baos.write(crlf);
         current += recordLen;
    xmlpayload.setContent(baos.toByteArray());
    inputModuleData.setPrincipalData(msg);
    Edited by: Martin Lavoie Rousseau on Oct 6, 2010 9:08 PM

  • Merging two records in a single record for the same matnr,werks and bwart.

    Hi I have a requirement to merge two records into one single record using the quantity field from MSEG table.
    I am selecting two records from the table MSEG. Now for these two records i have to add the quantity values into one variable.
    Then there should be only one record for the same matnr,werks,bwart.
    Any suggestion would be appreciated.
    Regards,
    Amit

    hi,
    You can COLLECT statement only if all non key fields are numeric.
    This statement Adds all such fields and give us a single record.
    Regards
    Sumit Agarwal

  • Put 2 relevant records in a single row

    <p>Hello everybody,</p><p>I have a Attendance table, which has columns WorkDate. Schedule_IN_Time, Schedule_OUT_Time, Login_IN_Time, Login_IN_Time, Login_Type.</p><p>Now for every Login_Type = "I" or "O" there are two records. That means for a day say 07/10/2006 as Workdate there are two records like,</p><p>EmpID WorkDate Schedule_IN_Time  Schedule_OUT_Time  Login_IN_Time  Login_OUT_Time  Login_Type</p><p>1          07/10/2006    09:00                   17:00                      9:00                                          I</p><p>1          07/10/2006    09:00                   17:00                                               17:15               O</p><p>NOW.. I want a report in Crystal report which will have a single record for a single Workdate..as folllows</p><p>EmpID WorkDate Schedule_IN_Time  Schedule_OUT_Time  Login_IN_Time  Login_OUT_Time</p><p>1          07/10/2006    09:00                   17:00                      9:00                   17:15                       </p><p>Can you please help me out..I&#39;m usng CrystalReport XI.</p><p>Thanks in advance.</p><p>sauren </p>

    Once you group on these put summaries for Max on each of the values you want to display as one line.  Put them in the footer and suppress the details. That should give the desired results.
         - Kathryn Webster (Report Design Consultant)
               Kat&#39;s News: http://diamond.businessobjects.com/blog/279

  • How to identify missing records in a single-column table?

    How to identify missing records in a single-column table ?
    Column consists of numbers in a ordered manner but the some numbers are deleted from the table in random manner and need to identify those rows.

    Something like:
    WITH t AS (
               SELECT 1 ID FROM DUAL UNION ALL
               SELECT 2 ID FROM DUAL UNION ALL
               SELECT 3 ID FROM DUAL UNION ALL
               SELECT 5 ID FROM DUAL UNION ALL
               SELECT 8 ID FROM DUAL UNION ALL
               SELECT 10 ID FROM DUAL UNION ALL
               SELECT 11 ID FROM DUAL
    -- end of on-the-fly data sample
    SELECT  '[' || (id + 1) || ' - ' || (next_id - 1) || ']' gap
      FROM  (
             SELECT  id,
                     lead(id,1,id + 1) over(order by id) next_id
               FROM  t
      where id != next_id - 1
    GAP
    [4 - 4]
    [6 - 7]
    [9 - 9]
    SQL> SY.
    P.S. I assume sequence lower and upper limits are always present, otherwise query needs a little adjustment.

  • How to insert multiple records in a single query

    Dear all,
    Can you please tell
    how to insert multiple records in a single query ??

    INSERT INTO table_name (column_1, column_2) VALUES ('value_A', 'value_B')OR
    INSERT INTO table_name
    (column_1, column_2)
    SELECT 'value_A', 'value_B' FROM DUAL
    UNION ALL
    SELECT 'value_C', 'value_D' FROM DUAL
    ;Edited by: Benton on Nov 9, 2010 1:59 PM

  • Multiple records as a single transaction in JDBC Receiver Adapter

    Hi,
    I am sending multiple records in a single message to a JDBC receiver adapter to get updated to the database. How to make all the insert a single transaction. Like all the records has to be inserted else all has to be rolled back.
    For eg for table Employee two fields EMPNO and EMPNAME
    EMPNO  EMPNAME
    1            Jay
    2            Christie
    These two records are in the same message and has to be updated
    if one fails the other has to be rolled back.
    How can i achieve it using a JDBC Receiver Adapter.
    Thanks
    Sebin

    Hi Rolf Micus,
    My xml structure to insert 2 tables are as follow:-
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:MT_PODB xmlns:ns0="http://abeam.com/xi/fer_filejdbc_scenarios1">
    ..   <STATEMENT_HEADER>
    ....      <ROW action="INSERT">
    ......         <TABLE>ZPO_HEADER</TABLE>
    ......        <access>
    ........            <PONUMBER>001</PONUMBER>
    ........            <PODATE>20070801</PODATE>
    ........            <POAMOUNT>200.99</POAMOUNT>
    ....         </access>
    ....      </ROW>
    ..   </STATEMENT_HEADER>
    ..   <STATEMENT_DETAIL>
    ....      <ROW action="INSERT">
    ......         <TABLE>ZPODETAIL</TABLE>
    ......         <access>
    ........            <PONUMBER>001</PONUMBER>
    ........            <PONO>1</PONO>
    ........            <POITEMCODE>A12345</POITEMCODE>
    ........            <POITEMDESC>Testing A</POITEMDESC>
    ........            <POITEMAMOUNT>2990.00</POITEMAMOUNT>
    ........            <POITEMQTY>55</POITEMQTY>
    ......         </access>
    ....      </ROW>
    ..   </STATEMENT_DETAIL>
    </ns0:MT_PODB>
    Fro the structure that you have declared..there is only contained 1 statement, try to admend your MT to have 2 statements.
    If you wish to insert multiple records, just create a loop/multiple of access tag inside STATEMENT tag. For example, multiple records insert into Header should have multiple access tag in Header STATEMENT. Same goes for muliple records insert into Details STATEMENT should have multiple access tag in Details STATEMENT.
    With this structure, whenever any records insert/update/delete failed...it will rollback all the transactions together, ie. Header and Details.
    PS: For different table, please create different STATEMENT.
    Hope it helps.
    Message was edited by: Pua Ming Fei

  • Retrieving record from oracle DB very slow..pls help

    Hi, i'm writing a VB code to retrieving records from Oracle DB Server version 8. I'm using VB Adodb to retrieve the records from various tables. Unfortunately one of the table are very slow to response, the table only contain around 204900 records. The SQL Statement to retrieve the records is a simple SQL Statement that contain WHERE clause only. Any issue that will make the retrieving time become slow? Is that a Indexing? Oracle Driver? Hardware Spec? Or any solution for me to improve the performance. Thanks!

    Well, there are a few things to consider...
    First, can you try executing your query via SQL*Plus? If there are database tuning problems, your query will be slow no matter where you run it.
    Second, are you retrieving significantly more rows in this query than in your other queries? It can take a significant amount of time to retrieve records to the client, even if it's quick to select them.
    Justin

  • How can we configure or control records go into single idoc thru BODS?

    Hi,
    Our case is -
    IDOC format has three segment. Each segments has child nodes -
    1. CONTROL SEGMENT - This is required only once per idoc.
    child1
    child2
    2. SEGMENT1 - sinlge source record to be broken into two segments.
    child1
    child2
    3. SEGMENT2 - sinlge source record to be broken into two segments.
    child1
    child2
    we have a single source (lest say having 100 records).
    In the current design which does generates IDOCS but as many as the no of records in source. Currently we use a row generation transform as dummy (with row count as 1) to pass to the IDOC parent nodes's from clause to escape the error - invalid input to the parent nodes.
    Child nodes are either mapped to the source table or are null.
    Question - How can we configure this in a way that we control how many records go into single idoc. Ex - lets say 50 per idoc so only 2 idoc should be created if 100 records are there.

    HI,
    this sounds to me like Data Services. If so I would suggest to post this into the Data Service forum.
    regards
    Ingo HIlgefort

  • Retrieving records using SQL Date Queries

    Hello,
    I am using Lab Windows CVI 8.5 and also SQL TOolkit for my project. I am using DBMapColumnToChar function for mapping Date to the database. And for retrieving records I am using SQL Query as follows:
    SELECT * FROM DBTable WHERE DATE_TABLE BETWEEN '%s' AND '%s'",cCurrentDate,cCurrentDate
    I have given a drop down for selecting dates.
    When I execute the query I am not getting the selected date values an instead I am getting some records for which the dates aren't selected...
    Quick help needed for this..Thanks in advance

    Depending on the database, the date/time structure can be completely different from the structure in CVI.  CVI uses the Windows format for time(), that is the number of seconds since 1900.  The tm struct can break this apart into a date and time structure that is usable.
    I am using MS Access for the databases and SQL toolkit.  I finally ended up replace the date field with an INT field format, and then store the CVI time (gotten with time()) as an INT value.
    Easy then to get a search range, store it a tm struct and then convert with mktime() to a calendar time to search with.
    Hope this helps.  The date/time thing is a never ending struggle.
    Regards, David E.

  • C# retrieving records

    I am trying to retrieve records from a table using the code below, but I always get no records even though I know there are records in the table because I am checking with SQL+
    Can anyone help please ?
    try
                             using(OleDbConnection conn_oracle = new OleDbConnection(source))
                                  conn_oracle.Open();
                                  // store subsystem and update Lane statics
                                  string select = "SELECT * FROM pvdba.Subsystem";                               
                                  OleDbCommand cmd = new OleDbCommand(select, conn_oracle);
                                  OleDbDataReader reader = cmd.ExecuteReader();
                                  while(reader.Read())
                                       if(reader.IsDBNull(0) == false)
                                            m_nSubSystem = (int)reader[0];
                                       if(reader.IsDBNull(3) == false)
                                            Lane.s_sFilePath = (string)reader[3];
                                       if(reader.IsDBNull(4) == false)
                                            Lane.s_sSanderson = (string)reader[4];
                                       else
                                            Lane.s_sSanderson = ""; // SOO 1/9/2003 1.0.0.9
                                       if(reader.IsDBNull(5) == false)
                                            Lane.s_sOasis = (string)reader[5];
                                       else
                                            Lane.s_sOasis = ""; // SOO 1/9/2003 1.0.0.9
                                       if(reader.IsDBNull(6) == false)
                                            Lane.s_sOverViewPath = (string)reader[6];
                                       if(reader.IsDBNull(2) == false)
                                            m_sSubSystemName = (string)reader[2];
                                       //     Lane.TheMainForm = this;
                                  reader.Close();

    Please post your questions at forum for OLEDB for Oracle:
    Oracle Provider for OLE DB
    Regards
    Jagriti

  • Unable to retrieve records with search criteria

    Hi All,
    I am trying to retrieve records based on search criteria as below, but not able to retrieve records.
    I created a search Search s=new Search(repSchema.getTableId("Customers"));
    Search s=new Search(repSchema.getTableId("Customers"));
              SearchGroup sg = new SearchGroup();
    FieldSearchDimension fsdCustFinValidated = new FieldSearchDimension(new FieldId(repSchema.getFieldId("Customers", "Financially_Validated")));
    BooleanSearchConstraint bSearchComm_Validated = new BooleanSearchConstraint(false);
    s.addSearchItem(fsdCustFinValidated, bSearchComm_Validated);
    s.setComparisonOperator(Search.AND_OPERATOR);     
    FieldSearchDimension fsdMaintableType = new FieldSearchDimension(new FieldId(repSchema.getFieldId("Customers", "Company_Type")));
    TextSearchConstraint tscCustType = new TextSearchConstraint("CUSTOMER", TextSearchConstraint.EQUALS);
    s.addSearchItem(fsdMaintableType, tscCustType);
    s.setComparisonOperator(Search.AND_OPERATOR);
    Calendar calCreate = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
    calCreate.add(Calendar.DATE,-6);
    System.out.println("customerCreditEscalation: calCreate:" + calCreate.getTime());
    FieldSearchDimension fsdMaintableDate = new FieldSearchDimension(new FieldId(repSchema.getFieldId("Customers", "Financially_Validated_Trigger")));
    SearchConstraint srchConstCreateGE = new DateTimeSearchConstraint(calCreate,DateTimeSearchConstraint.LESS_THAN_OR_EQUAL_TO);
    sg.addSearchItem(fsdMaintableDate,srchConstCreateGE) ;
    sg.setComparisonOperator(Search.AND_OPERATOR);
    Calendar calCreate1 = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
    calCreate1.add(Calendar.DATE,-7);
    SearchConstraint srchConstFinVldTrgrDate = new DateTimeSearchConstraint(calCreate1,DateTimeSearchConstraint.GREATER_THAN_OR_EQUAL_TO);
    sg.addSearchItem(fsdMaintableDate, srchConstFinVldTrgrDate);
    s.addSearchItem(sg);
    Basically I am trying to search using A=a and B=b and (C=c and D=d) where (C=c and D=d) is the search group.
    Please let me know if I am doing anything wrong.
    Thanks
    -Sai

    Hi Greg,
    Thanks for the answer. I am trying to do a search as below.
    Earlier in the blog I mentoned A=a and B=b and (C=c and D=d) where (C=c and D=d) is the search group, but my search is
    A=a and B=b and (C=c and C=d) . C is the same dimension, which is a timestamp field.
    I am getting my results with A=a and B=b and C< c where C is Timestamp field. But my requirment is equal to a date older than two days. So when I try equal A=a and B=b and C=c  it is not working(may be because it is timestamp field and c is a calendar ). So I am trying to do A=a and B=b and (C<c and C>d) so that I get records that fall with in those days. So for (C<c and C>d) I am creating a search group and adding it to search which is not giving me the rows.
    Hope I explained it ok.
    If you know of any samples please let me know.
    Regards
    -Sai

Maybe you are looking for

  • Invoice Table

    Hi all, i want to develop a report for PO line item status. for that, displaying fields are "po no, podate, lineitem,mat code,mat desc,uom,po qty,ven code, vend name,GR no,GR date,GRqty,GR vlaue, IR no, IR date, IR qty, IR value." what is the table f

  • Printer claim code, printer laserjet 600

    Hi, To get the printer claim code, I enter the IP address listed on the configuration page but I keep getting "problem loading page," so I cannot connect to the HP Embedded Web Server.  I've triple-checked the IP address so I know I'm not entering it

  • Function module to get order data from delivery

    hi , is there any function module to which i can pass the delivery number and get the order number (s) and other data . basically i want the order currency. pls help. <removed by moderator> Edited by: Mike Pokraka on Aug 21, 2008 9:44 AM

  • [BPM Email Feature] How to setup Emails?

    Hi There, I'm an enthusiast of this cool product of oracle and I'm wondering how can I make my system send emails, one of my activity contains this code which was written in the training material im using: do      Mail.from = "[email protected]";    

  • ActionScript 3.0 Programming...Formatting Text

    I'm a beginner, college student working on an assignment,  in ActionScript coding.  I have an ActionScript (.as) Class linked to my .swf.  I've got a Text Field and I want to format the text in...color, font, etc.  No matter what I do, the text "Hell