SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2004
    Location
    TX
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ACCESS...how do you INSERT a record to the TOP of a table?

    I know how to insert record data, but by default it will insert as the last record in the table, is there a way to insert it as the top row?

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,251
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    you need to take a step back from your question and consider this:

    in a relational database table, there is no such thing as position

    there is no first row, there is no last row

    you're thinking of physical files, and relational database tables aren't like that

    "first" and "last" have meaning only in the context of a SELECT statement which includes an ORDER BY clause

    okay, now that that's out of the way, can you give a more detailed example of what you'd like to do?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2004
    Location
    TX
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Right on rudy, I hear what you're saying. A peer actually helped me come to that conclusion a few hrs after I posted.

    The problem was this...

    Code in java was executing a query and returning a result set, user does this and that, btn clicked and front end stuff called a method (let's call it A) where an INSERT on the table was exec'd. Later in the code when I need to put the new result set in a loop it was catching an error, the "while next()" would fail and my catch block would execute. If method A exec'd w/out ever having the INSERT happen, the loop would work ok, everytime. When I did the INSERT and THEN called method A, the next() condition would fail and my catch block would execute. I think that after I did the insert there was maybe a cursor left @ the bottom of the result set? Either way I just brought in a fresh result set and it worked out ok. I was thinking I could just INSERT the data to the "top" row of the table so that the next() wouldn't fail when the loop started checking to see if there were additional rows to be iterated. That idea is down the gutter though.

    Thx for the explaination on the relational DB though...someday I'll have a more firm standing on DB.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •