Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Merge Into like in Oracle to Foxpro 9

Merge Into like in Oracle to Foxpro 9

Merge Into like in Oracle to Foxpro 9


Is there a Merge Into in Foxpro 9 like what Oracle does?

From my previous thread in my table, I already have duplicate records that I wanted to delete the old one and retain the latest as-of-date. So now instead of inserting all records at once, I wanted to check if the new record has similar values to the old one before I update/replace or append it to the main table.

Update = with same rg+div+sta+empno but different as of date
Append = new records

Thank you!

RE: Merge Into like in Oracle to Foxpro 9

YYou could try to do an UPDATE first with the WHERE conditions. If _TALLY = 0, then there was not a record found, and you could then do an INSERT. You would need to also include the current record date as part of the WHERE clause and use date > ldDate as the condition. Something like:

CODE -->

SELECT mytable
SCATTER MEMO NAME loRecord UPDATE mytable SET field1 = loRecord.field1, field2 = loRecord.field2, etc. ;
WHERE rg = loRecord.rg AND div = loRecord.div AND sta = loRecord.sta AND empno = loRecord.empno AND date > loRecord.date
INSERT INTO mytable (rg, div, sta, empno, date, etc) VALUES (loRecord.rg, loRecord.div, loRecord.sta, loRecord.empno, loRecord.date, loRecord.etc)

Where etc refers to the additional fields of the table.


RE: Merge Into like in Oracle to Foxpro 9

You could do something like this:

CODE -->

SELECT <the table you are updating>
LOCATE FOR <condition to indicate that the record is already in the table>
REPLACE <the fields that need to be updated> 


Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close