Results 1 to 10 of 10
  1. #1
    Join Date
    Jul 2009
    Posts
    26

    Unanswered: Need Help for a query

    Hello EveryOne,
    I have a task which is making me crazy to find the solution
    The task is
    ------------------
    1)Lets say i am having an table where i have 10 rows.
    I will execute the query to get the all the rows in the table and i will note down the time when i have retrieved the rows.
    NotedTime = date;

    2)Now after some time i wanted to fire a query which should return be back the rows entered after the time stamp what have noted.. that is ntohing but notedtime...
    i dont know any thing about the table i mean how many columsn are there or the data type anything...

    Is it possible to fire such query ...
    I tried searching in google about this probem but i could not find any information..
    I would really appreciate if some one can reply..
    Please let me know if the question is not clear...

    Thanks,
    Swati

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    If the table has a column of type timestamp that gets set to the current time when a row is inserted, then yes it is possible to do what you want.

    Andy

  3. #3
    Join Date
    Jul 2009
    Posts
    26
    Yes i do agree with your answer..I dont have timestamp in my data base table...I can not add or update the existing table that is the requirement..
    Now is it possible....

  4. #4
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    No, it is not.

    Andy

  5. #5
    Join Date
    Nov 2005
    Location
    IL
    Posts
    557
    I was going to ask if you can see how many fingers I am holding up, but then it hit me...

    If the mountain wont come to you, you should go to mountain. What I mean by this and this is really crazy to do it and I would not want to do it this way, but that is me.

    Can you create a trigger on this table? You are not changing the table per say. If yes, create a trigger that will get fired up on any IUD and writes PK to a temp table along with putting timestamp into it. Then you can do what you are asking. But as I said, I would be against this method if it was presented to me
    --
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows

    DB2 v9.7.0.6 os 6.1.0.0

  6. #6
    Join Date
    Jul 2009
    Posts
    26
    Hello Guys,

  7. #7
    Join Date
    Jul 2009
    Posts
    26
    Hello Guys,
    As a part of my research for the above issue.
    I came to know about some thing called "ROWID"
    For every DB2 table all the ROWIDs will be stored in some system table.
    If i can get the the last rowID of a table before doing my stuff.
    once i am donw with my stuff can i check in the same system table that after that noted rowid is there any new rowids....?
    If yes then how what could be the query..

    I would really appreciate if some one can help me out on this issue.

    Thanks,
    Swati

  8. #8
    Join Date
    Oct 2007
    Posts
    246
    rowid for table
    select row_number() over(), column_name from tabname
    its there in table itself, does it stores in system tables , i m not sure on this ??
    regds
    Paul

  9. #9
    Join Date
    Jul 2006
    Location
    Pune , India
    Posts
    433
    which version are you on ?

    9.5 : Optimistic locking

    RID_BIT and RID scalar functions
    Rahul Singh
    Certified DB2 9 DBA / Application Developer

  10. #10
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    Quote Originally Posted by swati malla
    Hello Guys,
    As a part of my research for the above issue.
    I came to know about some thing called "ROWID"
    For every DB2 table all the ROWIDs will be stored in some system table.
    If i can get the the last rowID of a table before doing my stuff.
    once i am donw with my stuff can i check in the same system table that after that noted rowid is there any new rowids....?
    If yes then how what could be the query..

    I would really appreciate if some one can help me out on this issue.

    Thanks,
    Swati
    The ROWID would be assigned by the database when the row is inserted. If rows are deleted, my guess is that DB2 will reuse the ROWIDs of the deleted rows. Also if a reorg occurs, the ROWIDs will change. You really cannot rely on this method. You really have to have a column that designates when the row was touched, so you can use that.

    Andy

Posting Permissions

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