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 > Pervasive.SQL > Stored Procedures

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-09-05, 19:33
Manah Manah is offline
Registered User
 
Join Date: Feb 2005
Posts: 19
Stored Procedures

Does any one know where I can find an example of a stored procedure that compares data file B to A.

I need to work out how to set up a procedure that will compare a temp data file with an original data file so that it can choose whether to update existing records or if that record doesn't exist insert a new one.

Thanks
Reply With Quote
  #2 (permalink)  
Old 03-09-05, 19:59
mirtheil mirtheil is offline
Registered User
 
Join Date: Dec 2001
Posts: 1,026
Personally, I wouldn't use a Stored Procedure. You're going to make things more complex and possibly run slower. It sounds like you're trying to write a simple replication process.
To do that through a Stored Procedure, you'd have to read each record from table one, then try to read it from the second table and update it if it exists (and is different) or insert it if it doesn't exist in the second table. Don't forget that a Stored Procedure will only run when you call it. You could possibly write this as a program and kick it off just as easily.
__________________
Mirtheil Software
Certified Pervasive Developer
Certified Pervasive Technician
Custom Btrieve/VB development
http://www.mirtheil.com
I do not answer questions by email. Please post on the forum.
Reply With Quote
  #3 (permalink)  
Old 03-09-05, 22:45
Manah Manah is offline
Registered User
 
Join Date: Feb 2005
Posts: 19
Sorry, but I'm new on this SQL stuff. I would have thought that a Stored procedure would have allowed for error trapping and rollbacks.

How does this replication work? Are you suggesting that I call in each record and test to see whether they exist, If it doesn't, then do an insert, else if the record exist, do a test on each field to determine if the field needs to be updated.
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On