Getting the last added record

Hi,
Am developing an application that needs to record some info in a user table after adding a sales invoice. What i need is an object or method that could give me the info of the last record added in the AR invoices table, i tried using the GetNewObjectKey() but i'm not sure if this method works OK in a scenario where concurrence situations could be present, i mean in situations where multiple users could save documents at the same time, does not the method become imprecise?

Hi Oscar,
Have a look at the following post:
Re: Getting the Document Number
Hope this helps,
Owen

Similar Messages

  • Query to get the last added record in a table for a particular id

    T
    Hi,
    I have 2 tables A, B
    Table A has id,name
    Table B had parentid(foreignkey referring to ID in above table), record_type,created_timestamp
    I want to get the last added record_type from Table B for all the ids present in Table A.

    Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules. I know this is
    a skeleton, but could you at least try to do good programming? Temporal data should use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect. 
    This is minimal polite behavior on SQL forums. And sample data also helps. 
    I have 2 tables: Alphas, Betas
    CREATE TABLE Alphas
    (alpha_id CHAR(10) NOT NULL PRIMARY KEY,
     alpha_name VARCHAR(25) NOT NULL);
    Why was that DDL so hard you could not write it? But your narrative about the second table does not tell us if it has a key. I will guess that it is also alpha_id, but thanks to your rudeness, that is all we can do. 
    CREATE TABLE Beta 
    (alpha_id CHAR(10) NOT NULL PRIMARY KEY
       REFERENCES Alphas (alpha_id),
     record_type CHAR(2) NOT NULL,
     creation_timestamp DATETIME2(0) DEFAULT CURRENT_TIMESTAMP
          NOT NULL,
    >> I want to get the last added record_type from Table Beta for all the ids present in Table A.<<
    Think about this. Since Beta.alpha_id is a FOREIGN KEY to Alphas, all of its rows will have a match to Alpha. The SQL engine does this for you! 
    SELECT *
    FROM (SELECT alpha_id, record_type, creation_date,
                  MAX(creation_date) OVER () AS creation_date_max
            FROM Betas)
    WHERE creation_date = creation_date_max;
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Different ways to get the last 5 records ordered by date

    I have a query no that returns the tickets ordered by moddt, modification date,
    I was thinking of adding a select on top, to get the last 5 records of that list the select already generates. An other way was to use that select to create a view,
    and get the 5 last records that way. I also though of a possibly impossible cursor with a sequence, but hmm well I consider that not a good solution.
    So I'm trying to find a way, using a select, the topmost select which is not completed yet, to get the last 5 records. Maybe I should just try the rownumber thing again or something likewise.
    Select * from(
    select * from(
    Select ticketid, appliecatiecd, categorieid, substr(titel,&,200)||' ...' "titel", klantproriteitid, interneprioriteitid,
    (select g.voornaam||' '||g.naam
    from gebruiker g
    Where g.gebruikerid = t.gebruikerid
    And t.applicatiecd = NVL(:P0_applicatiecd, :F101_applicatiecd))"aangemaakt door",
    (select s.statusdefoms "status"
    From status s
    Where s.statusid = t.statusid
    And t.applicatiecd = NVL(:P0_applicatiecd, :F101_applicatiecd)) "status",
    Versieid,
    Moddt,
    Row_number() over (order by ticketid desc) rn
    From ticket t
    Where applicatiecd = NVL(:P0_applicatiecd, :F101_applicatiecd) )
    Order by moddt)
    Where --

    Hi Floris,
    You can also use RANK: http://www.dba-oracle.com/oracle_news/oracle_faq/faq_beg_sql_top_n_rows.htm
    Regards Pete

  • How can I get the last / newest record of a table?

    Hi,
    I am developing an ecard app that has a create greeting page, a preview page with edit and send buttons and an edit page.
    I got he insert working, and on the preview page I created a master record page (displays all records), and delete all unecessary designs. Doing it this way also gives me the 'edit' button, so people are able to edit their page.
    How do I get only the last record displayed though? At the moment it loops through all records and displays them in sets of 10. I found the variable that holds the totla count of records ('$totalRows_rs7417_content1'), but how do I (re-)write the script so it ONLY diplays the last record?
    I need to get the ID of this record as I am writing this into the PARAMs of the object and embed tags of my message .swf (this picks up the ID and based on that sucks the greetings text out of the database via another php script.
    Also, from this page, how can I send an email to the sender (ie creator of the message) as well as the recipient? Both email addresses are in the databse so should be part of the erecord returned.
    Thanks,
    Nik

    -----
    OK, So how do I recreate what I got in a non-ADDT list?
    well, when you´re just about to display one certain record, the term "list" is somewhat inappropriate anyway.
    What you´d simply need to do IMHO, is using DW´s native functions to create the basic "SELECT * FROM table_name ORDEr BY ID DESC" query, add "LIMIT 1" manually, and display the desired "dynamic text" placeholders in 1 table cell -- don´t think there were any need for all the fancy stuff
    (sorting, filtering etc) provided by ADDT´s list, as it´s just 1 record.
    It also occurred to me just now that finding the last record that has been added *may-* notbe enough if the site gets used a lot by our executives (I am thinking of a situation where 2 or three peolpe create greetings at the same time and press submit and then getting each others messges rather than their own).
    in this case you might want to additionally store the respective executive´s "kt_login_id" session variable -- because it´s this unique "identifier" which should be used to show the last inserted record of the person who actually inserted it, means adding a "WHERE submitter_id" equals the session variable kt_login_id - clause to the query.
    When creating a non-ADDT list that´s at some point based on detecting a user session, you´ll BTW need to insert at line 1
    I can't seemt o insert it on the page as it is looking for a insert, update or delete bahaviour on the page which of course I don't have
    please search these forums for several posts I made which explain my "use dummy table" approach that´s made for cases when you actually don´t have anything to insert/update/delete, but need "something" for ADDT´s send email behaviours.
    Cheers,
    Günter Schenk
    Adobe Community Expert, Dreamweaver

  • How to get the last inserted record from a table ?

    :-) Hiee E'body
    I work on Oracle 8i and need to get the last
    record inserted in a table.
    I have tried using rownum and rowid pseudo-columns
    but that doesn't work.
    Can you please help me out ?
    :-) Have a nice time
    Vivek Kapoor.
    IT, Atul Ltd.,
    India.

    I'm not sure about 8i features.
    I assume here that you don't have 'Date-Time' stamp columns on the table which is the easiest way to determine the last inserted row in the table.
    If not try the following :-
    select address, piece, SQL_TEXT
    from V$SQLTEXT
    where upper(sql_text) like '%INSERT INTO TABLE_NAME%'
    Substiute the TABLE_NAME with the name of the actual table.
    Have fun.
    Regards,
    Shailender
    :-) Hiee E'body
    I work on Oracle 8i and need to get the last
    record inserted in a table.
    I have tried using rownum and rowid pseudo-columns
    but that doesn't work.
    Can you please help me out ?
    :-) Have a nice time
    Vivek Kapoor.
    IT, Atul Ltd.,
    India.

  • Problem getting the last database record

    I need to get the last record of my database. The only way i found to do this is to use cursor::get with DB_LAST flag.
    But using it i don't always get the last record. For instance if the database contains 5000 records i am getting record number 4864 and so on.
    What am i doing wrong?

    The DB_LAST flag is the right one to use.
    Are you sure the keys sort in the order you expect? In particular, check for little endian integers. Here is some Python code that might be instructive:
    import struct
    sorted([(struct.pack("<i", i), i) for i in xrange(5000)])[-1][1]Regards,
    Michael Cahill, Oracle Berkeley DB.

  • Getting the last 5 records

    I was told I should do this by date, and not buy a number. He might still be right that by date is better. But I thought that by ticketnr makes also sense, because the latest ticket, is wel normally the most recent one. I've added the check although it might not be needed, so I may remove it later.
    The idea behind it is that if, although a field that needs to be filled in would give an error if not being so, a field that needs to be filled in, isn't then that record can't be used. As that wouldn't be the case, I can remove that as well. That would make it less complex.
    The idea was that records could have been deleted, so that you get 1185 1187 1188 1189 1190 . If you just take the 5 highest ticket numbers, you would only get 4 as one is missing. So I thought that if you include a check that check if the ticketid actually used or not. I suppose it would be nicer if one could write something similar to but therefore not the same:
    if tikcetid(select ticketid into ticketidtotest from ticket where ticketid=tussenticketid;).used() = TRUE then;
    Then you would be sure it is used, and it would just pick out the last 5 ones. There could be a problem with the dates if they are mixed up, but this could be a problem not just for this. So I think it would deserve a solution on the database.
    I'm getting one error as it is now.
    Error report:
    ORA-06550: line 83, column 20:
    PLS-00103: Encountered the symbol "=" when expecting one of the following:
    . ( * @ % & = - + < / > at in is mod remainder not rem then
    <an exponent (**)> <> or != or ~= >= <= <> and or like
    between || multiset member SUBMULTISET_
    06550. 00000 - "line %s, column %s:\n%s"
    *Cause:    Usually a PL/SQL compilation error.
    *Action:
    This is about the last : Tussen_ticketid := Tussen_ticketid - 1; But isn't it normall like it stands there ?
    DECLARE
    Mrecent_ticket NUMBER;
    Tussen_ticketid NUMBER;
    Ticketid_Place2 NUMBER;
    Ticketid_Place3 NUMBER;
    Ticketid_Place4 NUMBER;
    Ticketid_Place5 NUMBER;
    Ticketid_Place1 NUMBER;
    TestVeld VARCHAR2(2000);
    Query_to_use VARCHAR2(4000) := ' SELECT ticketid, applicatiecd, '||
    ' categorieid, titel, klantprioriteitid, interneprioriteitid, gebruikerid, statusid,'||
    ' versieid FROM ticket WHERE ticketid =';
    Start_Rec_ticketid NUMBER;
    TestVeldFoundThatIsCorrect NUMBER; is NULL; BOOLEAN := FALSE;
    BEGIN
    -- TestVeldFoundThatIsCorrect := FALSE;
         SELECT Max(Ticketid) INTO Mrecent_ticket FROM Ticket ;
         Tussen_ticketid := Mrecent_ticket;
         -- of dit echt nodig is weet ik zo niet
         -- kan eventueel opgevangen worden in de hoofd loop
         -- TestVeldFoundThatIsCorrect := FALSE;
         -- mischien checken op datum die ingevuld is, die moet ingevuld zijn wil het ok zijn
         LOOP From top to bottom  Till TEstVeldFOUNDTHATISCORRECT is TRUE
         WHILE TestVeldFoundThatIsCorrect != 9999999 LOOP
                   SELECT titel INTO TestVeld FROM ticket WHERE ticketid =
                   Tussen_ticketid;
              IF TestVeld is NULL THEN
                   Tussen_ticketid := Tussen_ticketid - 1;
                   TestVeld := NULL;
              ELSE
                   TestVeldFoundThatIsCorrect := 9999999;
                   Start_rec_ticketid := Tussen_ticketid;
                   --Stop loop
              END IF;
         END LOOP;
         IF TestVeldFoundThatIsCorrect = 9999999 THEN
              Tussen_ticketid := Start_rec_ticketid;
              -- standaard is het onderstaande, bovenstaande gebeurt alleen als de bovenstaande loop
              -- gebruikt is
         ELSE
              Tussen_ticketid := Mrecent_ticket;
         END IF;
         -- mischien moet er nog een count gebeuren die kijkt hoeveel tickets er zijn in een bepaalde --
         -- periode en afhankelijk daarvan, tussen wanneer en wanneer een andere flag zetten
         --LOOP TELLER BETWEEN 1 AND  6
         While teller <= 5 LOOP
              SELECT titel INTO TestVeld FROM ticket WHERE ticketid = Tussen_ticketid;
              --Veld_dat_ingevuld_moet_zijn INTO  TestVeld FROM ticket WHERE ticketid = Tussen_ticketid;
              -- dit zou het datumveld moeten zijn
              IF TestVeld is NOT NULL THEN
                   -- dan is dat record ok voor gebruik
                   -- wel nog nakijken welke veld dat moet zijn, moet altijd ingevuld zijn
                   -- waarde doet er niet toe
                   --Query_to_use := Query_to_use || ' UNION SELECT ticketid, applicatiecd, '||
                   --' categorieid, titel, klantprioriteitid, interneprioriteitid, gebruikerid, statusid,'||
                   --' versieid FROM ticket WHERE ticketid = ';
                   IF Teller = 1 THEN
    Ticketid_place1 := Tussen_ticketid;
    Query_to_use := Query_to_use || 'Ticketid_place1';
                   ELSIF Teller = 2 THEN
    Ticketid_place2 := Tussen_ticketid;
    Query_to_use := 'UNION'||Query_to_use || 'Ticketid_place2';
                   ELSIF Teller = 3 THEN
    Ticketid_place3 := Tussen_ticketid;
    Query_to_use := 'UNION'||Query_to_use || 'Ticketid_place3';
                   ELSIF Teller = 4 THEN
    Ticketid_place4 := Tussen_ticketid;
    Query_to_use :='UNION'|| Query_to_use || 'Ticketid_place4';
                   ELSIF Teller = 5 THEN
    Ticketid_place5 := Tussen_ticketid;
    Query_to_use :='UNION'|| Query_to_use || 'Ticketid_place5';
                   ELSIF Teller = 6 THEN
                        Teller := Teller + 1;
                   END IF;
                   Teller := Teller + 1;
                   Tussen_ticketid := Tussen_ticketid - 1;
              ELSIF
                   Tussen_ticketid := Tussen_ticketid - 1;
              END IF;
         END LOOP;
         -- dbms_output.Put_line(Query_to_use);
         RETURN Query_to_use;
    END;

    DECLARE
    Mrecent_ticket NUMBER;
    Tussen_ticketid NUMBER;
    Ticketid_Place2 NUMBER;
    Ticketid_Place3 NUMBER;
    Ticketid_Place4 NUMBER;
    Ticketid_Place5 NUMBER;
    Ticketid_Place1 NUMBER;
    TestVeld VARCHAR2(2000);
    Query_to_use VARCHAR2(4000) := ' SELECT ticketid,
    applicatiecd, '||
    ' categorieid, titel, klantprioriteitid,
    interneprioriteitid, gebruikerid, statusid,'||
    ' versieid FROM ticket WHERE ticketid =';
    Start_Rec_ticketid NUMBER;
    TestVeldFoundThatIsCorrect NUMBER; --is NULL;
    --BOOLEAN := FALSE;
    EGIN
    -- TestVeldFoundThatIsCorrect := FALSE;
    Max(Ticketid) INTO Mrecent_ticket FROM Ticket ;
    ussen_ticketid := Mrecent_ticket;
         -- of dit echt nodig is weet ik zo niet
         -- kan eventueel opgevangen worden in de hoofd loop
         -- TestVeldFoundThatIsCorrect := FALSE;
    -- mischien checken op datum die ingevuld is, die
    e moet ingevuld zijn wil het ok zijn
    LOOP From top to bottom  Till
    l TEstVeldFOUNDTHATISCORRECT is TRUE
         WHILE TestVeldFoundThatIsCorrect != 9999999 LOOP
    SELECT titel INTO TestVeld FROM ticket WHERE
    ERE ticketid =
                   Tussen_ticketid;
              IF TestVeld is NULL THEN
                   Tussen_ticketid := Tussen_ticketid - 1;
                   TestVeld := NULL;
              ELSE
                   TestVeldFoundThatIsCorrect := 9999999;
                   Start_rec_ticketid := Tussen_ticketid;
                   --Stop loop
              END IF;
         END LOOP;
         IF TestVeldFoundThatIsCorrect = 9999999 THEN
              Tussen_ticketid := Start_rec_ticketid;
    -- standaard is het onderstaande, bovenstaande
    de gebeurt alleen als de bovenstaande loop
              -- gebruikt is
         ELSE
              Tussen_ticketid := Mrecent_ticket;
         END IF;
    -- mischien moet er nog een count gebeuren die kijkt
    t hoeveel tickets er zijn in een bepaalde --
    -- periode en afhankelijk daarvan, tussen wanneer en
    n wanneer een andere flag zetten
         --LOOP TELLER BETWEEN 1 AND  6
         While teller <= 5 LOOP
    SELECT titel INTO TestVeld FROM ticket WHERE
    RE ticketid = Tussen_ticketid;
    --Veld_dat_ingevuld_moet_zijn INTO  TestVeld FROM
    OM ticket WHERE ticketid = Tussen_ticketid;
              -- dit zou het datumveld moeten zijn
              IF TestVeld is NOT NULL THEN
                   -- dan is dat record ok voor gebruik
    -- wel nog nakijken welke veld dat moet zijn, moet
    oet altijd ingevuld zijn
                   -- waarde doet er niet toe
    --Query_to_use := Query_to_use || ' UNION SELECT
    ECT ticketid, applicatiecd, '||
    --' categorieid, titel, klantprioriteitid,
    id, interneprioriteitid, gebruikerid, statusid,'||
                   --' versieid FROM ticket WHERE ticketid = ';
                   IF Teller = 1 THEN
    Ticketid_place1 :=
    Tussen_ticketid;
    Query_to_use :=
    Query_to_use || 'Ticketid_place1';
                   ELSIF Teller = 2 THEN
    Ticketid_place2 :=
    Tussen_ticketid;
    Query_to_use :=
    'UNION'||Query_to_use || 'Ticketid_place2';
                   ELSIF Teller = 3 THEN
    Ticketid_place3 :=
    Tussen_ticketid;
    Query_to_use :=
    'UNION'||Query_to_use || 'Ticketid_place3';
                   ELSIF Teller = 4 THEN
    Ticketid_place4 :=
    Tussen_ticketid;
    Query_to_use :='UNION'||
    Query_to_use || 'Ticketid_place4';
                   ELSIF Teller = 5 THEN
    Ticketid_place5 :=
    Tussen_ticketid;
    Query_to_use :='UNION'||
    Query_to_use || 'Ticketid_place5';
                   ELSIF Teller = 6 THEN
                        Teller := Teller + 1;
                   END IF;
                   Teller := Teller + 1;
                   Tussen_ticketid := Tussen_ticketid - 1;
              ELSIF
                   Tussen_ticketid := Tussen_ticketid - 1;
              END IF;
         END LOOP;
         -- dbms_output.Put_line(Query_to_use);
         RETURN Query_to_use;
    END;WHat are you trying to achive by this code? Please explain this bolded script part. I didn't see any function is using here. But, you are returning one value to where? Or may be i overlooked it. Please explain it.
    Regards.
    Satyaki De.

  • Getting the Last 100 Records

    Dear all.
    I have a Table with 4 million reocords,
    Is there any way to view only the last 400 commands. Is there a command in oracle that gets the first 400 or last 400 records
    Kindly Suggest

    OK. Something like this will give you the last 400 from the most recent date(s).
    select *
    from
       select col1
             ,col2
             ,col3
             ,row_number() over (order by date_loaded desc) rn
       from   your_table
    where rn <= 400;

  • Last added record key for UDO

    Hi,
    I create a UDO , how i get the last added record key after i add document ?
    Please Advise. Thanks

    Hi,
    Or try oCompany.GetNewObjectCode().
    Or if this dosent work try the following.... Before adding the record in the before action = True execute a simple query 
    select max(docentry)  from OINV
    And now store that in a variable and execute the same query after the record is added in the beforeaction = false and check if both are same, if not then u have a new record added.
    Hope it helps,
    Vasu Natari.

  • How to get the last record from the database

    I am using MS Access database and Swings as GUI. I want to get the last record of a particular column from the table and store it as a varaible.

    Hi
    To get Last record of resultset, you have pass some parameter in constructor of CreateStatement.In such case Resultset should be scrollable and Readonly
    Example
    objStatement=objCon.createStatement ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
    mwwResultSet=cwwStatement.executeQuery(mwwSqlQuery);
    while(mwwResultSet.next())
    if(mwwResultSet.isLast())
    //Fetch the required column record.
    String abc=mwwResultSet.getString(1);
    I think this will work. Try it.
    bye

  • How to get the last time a record was modified or created ?

    Is there a way (hidden system fields for example, system view, other ?) to get the last time a record of a table was modified or the date it was created.
    Thanks for any help.
    Stiphane CAMPION

    blarman74 wrote:
    I know I could do this with a trigger, but I was wondering if there is a data dictionary view I can query to find the date/time a table was last updated. What I have is a table that is constantly getting hammered with new data being uploaded from a third party. We need to keep close tabs to verify that this datafeed is constantly running and bringing in new data. Because the data that comes in comes from multiple timezones and there are hundreds of lines, our attempts at monitoring by just looking at the data leave something to be desired.
    Any ideas?refer this links
    How to find Last modified/updated time of a particular table
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1590655700346557237
    Thanks

  • How to get the last record of an internall table ....

    Hi All..
    i want to get the last record of an internal table itab, and i want the the value of the last record.

    Hi,
         Use describe statment.
    data: lv_line type i.
        Describe table itab lines lv_line.
        read table itab into wa_itab index lv_line.
    regards,
    Santosh Thorat

  • Getting the last active number purchasing info record

    Hi,
    I was trying to get the last active number of the purchasing info record.
    As in the ME21N, while creating a purchase order, once we have entered the material number, the system automatically returns the adequate number of the info recored, but I could't identify (through debug) which was the function module or method call used to get it.
    I will be really thankful if somebody could help.
    Thanks & regards.

    Thanks to all for your answers. I finally figured it out with the help of a functional consultant.
    To identify the last active number purchasing info record, we retreive from table EINA, and there, the field LOEKZ should be empty.
    Basically, we only have one info record number per couple material/vendor.
    Ragards

  • How can i get the id of the last child record in hierarchical data

    I want to get the lastest child record  of the parents like 
    the result   
    If I Select A then the result should be  'C' , 'E' , 'F' , 'G'
    If i select D then the result should be 'F' etc
    Thanks
    USE [SMEDB]
    GO
    /****** Object:  Table [dbo].[Table_3]    Script Date: 11/26/2014 2:10:49 PM ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[Table_3](
    [ID] [nvarchar](50) NULL,
    [ParentID] [nvarchar](50) NULL
    ) ON [PRIMARY]
    GO
    INSERT [dbo].[Table_3] ([ID], [ParentID]) VALUES (N'A', NULL)
    INSERT [dbo].[Table_3] ([ID], [ParentID]) VALUES (N'B', N'A')
    INSERT [dbo].[Table_3] ([ID], [ParentID]) VALUES (N'C', N'D')
    INSERT [dbo].[Table_3] ([ID], [ParentID]) VALUES (N'D', N'A')
    INSERT [dbo].[Table_3] ([ID], [ParentID]) VALUES (N'E', N'D')
    INSERT [dbo].[Table_3] ([ID], [ParentID]) VALUES (N'F', N'E')
    INSERT [dbo].[Table_3] ([ID], [ParentID]) VALUES (N'G', N'A')

    WITH cte(ID, ParentID, Lvl, HPath)
    AS (
           SELECT ID,
                  ParentID,
                  0,
                  CAST(ID AS VARCHAR(MAX)) + '\' AS HPath
           FROM   dbo.[Table_3]
           WHERE  ID ='D'
           UNION ALL
           SELECT        e.ID,
                         e.ParentID,
                         m.Lvl + 1 AS Lvl,
                         m.HPath +CAST(e.ID AS VARCHAR(MAX))+ '\'  AS HPath
           FROM          dbo.[Table_3] AS e
           INNER JOIN    cte AS m ON m.ID = e.ParentID
    ),cte1
    AS
    SELECT HPath,id,Parentid,lvl,
    RIGHT(LEFT(HPath,LEN(HPath)-1),CHARINDEX('\',REVERSE(LEFT(HPath,LEN(HPath))))) lst
    FROM   cte WHERE lvl>0
    ) SELECT lst FROM cte1 WHERE NOT EXISTS (SELECT * FROM cte1 c WHERE c.ParentID=cte1.lst)
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • How to get the number of records of a streaming result set

    Hi guys.
    So if it wasn't a streaming result set, I would have done this:
    {noformat}myResultSet<code class="jive-code jive-java">.last();
    {color:navy}*int*{color} numResults = </code>myResultSet<code class="jive-code jive-java">.getRow();
    </code>myResultSet<code class="jive-code jive-java">.beforeFirst();
    </code>{noformat}
    but being a streaming result set, beforeFirst() throws an exception...
    So how do you get the number of records in that result set? I wanna avoid an extra count(*) query, so I would appreciate other solutions than that.

    JoachimSauer wrote:
    vanwil wrote:
    you see, for now I just use a count(*) query to get the number of records, but that's adding a lot of extra waiting time...Iterating over the result twice will surely be slower then doing the count(*).great! so what I got now is actually the fastest way there is... awesome...
    If you get an exception, then you surely have a stack trace. That should tell you what happens, or at least where.com.mysql.jdbc.MysqlIO.checkForOutstandingStreamingData(MysqlIO.java:2066)
    Why do you need to know the number of elements beforehand, anyway?I need to know the number of elements because the incoming data goes into a table. Now of course, I could use ArrayList<String[]> or something, but wouldn't that require more memory resources than Object[][] ?
    No one can tell you that, at least not without more information (say, the stack trace for example).Here's the exception message:
    java.sql.SQLException: Streaming result set com.mysql.jdbc.RowDataDynamic@10c0ef2 is still active. Only one streaming result set may be open and in use per-connection. Ensure that you have called .close() on  any active result sets before attempting more queries.

Maybe you are looking for

  • Can't send email from home

    I have a serious problem. My wife has a Mac Book Pro for work and she can send email at any location except from home. The error she is getting is Cannot send message using the server smtp.knology.net:(username) The server "smtp.knology.net" refuses

  • AP - Controller connectivity issue

    Hi, I am trying to connect a bunch of APs (1131) to a 4404 controller. The problem I have is that the APs, everytime I connect them to the local- to the controller- network they keep on rebooting. I have hardcoded the IP address of the APs, as well a

  • Import oracle apps dump into oracle database

    Dears, Is it possible to import the dump taken form oracle apps to oracle 11g. If it is possible could anybody list down the steps. Thanks Janani.C

  • Quality of pdfs and colour separations for printing purposes

    Having created a 44 page document in Pages, I have exported it as a pdf file so that it can be commercially printed as an A5 magazine. I have used the 'best' option in exporting it as a pdf, but have no idea if that function conforms to PDF-X1A speci

  • Web dynpro abap application stops responding?

    Hi Experts, I want to know in which case does the web dynpro for ABAP application stops responding. Does server roundtrip come into picture here? thanks, Arti.