If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Need Help for a query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-01-09, 15:26
swati malla swati malla is offline
Registered User
 
Join Date: Jul 2009
Posts: 26
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
Reply With Quote
  #2 (permalink)  
Old 10-01-09, 16:25
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
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
Reply With Quote
  #3 (permalink)  
Old 10-01-09, 16:38
swati malla swati malla is offline
Registered User
 
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....
Reply With Quote
  #4 (permalink)  
Old 10-01-09, 16:40
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
No, it is not.

Andy
Reply With Quote
  #5 (permalink)  
Old 10-01-09, 16:48
Cougar8000 Cougar8000 is offline
Registered User
 
Join Date: Nov 2005
Location: IL
Posts: 554
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.1.0.2 os 5.3.0.0
Reply With Quote
  #6 (permalink)  
Old 10-05-09, 20:10
swati malla swati malla is offline
Registered User
 
Join Date: Jul 2009
Posts: 26
Hello Guys,
Reply With Quote
  #7 (permalink)  
Old 10-05-09, 20:14
swati malla swati malla is offline
Registered User
 
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
Reply With Quote
  #8 (permalink)  
Old 10-06-09, 00:47
Mathew_paul Mathew_paul is offline
Registered User
 
Join Date: Oct 2007
Posts: 200
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
Reply With Quote
  #9 (permalink)  
Old 10-06-09, 01:29
rahul_s80 rahul_s80 is offline
Registered User
 
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
Reply With Quote
  #10 (permalink)  
Old 10-06-09, 08:31
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On