Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
INSERT and UPDATE Usage
Message
From
04/09/2008 00:38:44
 
 
To
03/09/2008 20:51:28
Jay Johengen
Altamahaw-Ossipee, North Carolina, United States
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01344701
Message ID:
01344722
Views:
13
>I have a scenario where I need to INSERT into a table, but only if the record does not already exist. If it does exist, then I want to UPDATE it. There are a couple key fields that I can use to do the matching. I have a table open in the current workarea, and some of the values from the current record are what get inserted/updated in the 2nd table that is open. What would be the best way to handle that?
>

Depends on your backend - with Oracle, you can use the Merge command. With a VFP backend, you can do something like
If Seek(...
    Replace fieldX With ... Next 1 In yourAlias
Else
    Insert Into ...
Endif
hth
-Stefan
Previous
Reply
Map
View

Click here to load this message in the networking platform