Hello, I have the view from a table that keeps incrementing with new
values, I have no control of this database, but I need to retrieve the
new values to insert it on my table (sql server) and send some
parameters of the database to another application, I'm using C# to get
access to both databases, so does anybody know of an efficient way to
retrieve only the new values of the database?
Thanks a lot
Luis Saavedra
Luis,
I don't think there is any general solution to your problem. I usually use triggers, but since you said you have no control on the db that won't work.
The only solution I can think of is to see it your table contains some identity column. If that is the case (and it often is), then you may just select data from the table with an identity column greater than the last you found. This will only work to get new additions to the db. It cannot detect deletions.
HTH
--mc
the problem is that the identity column appears to be autoincremental, but is not in all of the cases, for example I have something like
1001
1002
1003
1005
1007
1006
1004
what I have considered is using a counter (of the inserted registers) in a table of my database, then use a count of all the registers of the informix table and get a top (of the difference between these two tables), the problem is that if in the lapse between the count and the selection of the registers they insert something in the table of informix, I will be missing some values, any ideas to solve this or use another solution...
Thanks
Luis Saavedra
|||I think you're on the right track here. You might want to store the same values in that field from the source system in your own column in a table on your system. You can then compare based on a join. That might not work for you if there are a lot of values or it is updated a lot. In that case, is there a "Row Number" in your source database you can get at pprogramatically? If so, you could store the last value of that column, which will increment, in one row of your table and update based on it. Does that make sense? Something like this:
Source DB:
(Hidden RowNumber feature) IdentityColumn
(1) 1001
(2) 1002
(3) 1003
(4) 1005
(5) 1007
(6) 1006
Your DB:
Tracking Number IdentityColumn
(1) 1001
(2) 1002
(3) 1003
(4) 1005
Buck Woody
http://www.buckwoody.com
No comments:
Post a Comment