Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > Oracle
|
Oracle General Oracle database discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Oracle section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 14th, 2005, 12:43 AM
Registered User
 
Join Date: Jan 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default extracting last set of inserted records

hi,
I have a table in oracle 7.3. from which i have generate XML file.
The problem is, the windows service has to pick up the last inserted records only. Window service is accessing the database every time the timer elapsed. tell me the way to get the last inserted record without identity colum?

 
Old April 14th, 2005, 01:06 AM
Authorized User
 
Join Date: Apr 2004
Posts: 70
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Unless you are storing some sort of identifier that tells you what is "new", you cannot get just the most recent data.

Potentially, you could add a trigger to the table that would insert a row into a transaction table. The service could then pull data from that transaction table, apply the changes, and delete the change record. In more recent versions of Oracle, there are a variety of tools for tracking data changes that will be simpler and more performant than this trigger based approach.

Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC
 
Old April 14th, 2005, 01:23 AM
Registered User
 
Join Date: Jan 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks for your reply.

can u explian your idea in detail.

thanks in advance.


 
Old April 14th, 2005, 02:14 AM
Authorized User
 
Join Date: Apr 2004
Posts: 70
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If you have a table t1, you could create a table that stored the changes to t1, i.e. t1_change.

You could then create a trigger on t1 that wrote data to t1_change. Exactly what you would need to store would depend on the structure of t1, but it would presumably be something that uniquely identified the row. The primary key would be preferrable, though, you could use ROWID as well. The precise needs of the extract process will matter here as well. How are DELETE's handled? Do you need to extract the complete "before" image of the deleted row? What about for UPDATE's? Do you need to know the old data or just the new data? How are multiple changes to the same row handled? If I INSERT, UPDATE, and then DELETE a row between extracts, do you need to note all those changes or just the final status?

The extract process would read from t1_change, potentially do a lookup for the new data in t1, extract the data, and delete the row from t1_change.

Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC





Similar Threads
Thread Thread Starter Forum Replies Last Post
delay trigger until all records are inserted rob209 SQL Server 2000 5 March 26th, 2013 06:17 AM
set of records from procedures p330418 ASP.NET 2.0 Basics 1 March 31st, 2008 01:34 AM
Query to retrieve the first 10 records inserted anup_daware Oracle ASP 0 August 6th, 2007 01:50 AM
Double records inserted when using Insert Sach Classic ASP Databases 4 March 7th, 2006 02:29 PM
Populate a table with records from another set Golo Access VBA 9 November 10th, 2005 02:42 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.