Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check for Uniqueness when Appending data

Status
Not open for further replies.

shangrilla

Programmer
Nov 21, 2001
360
US
Hi:

I am appending data from one table to another table. Both tables have the same indexes, but each table is stored in a different location.


if not used('origTable')
use origTable
endif
if not used('appendTable')
use appendTable
endif
append from origTable where country = "USA"

Both origTable and appendTable have a field called "pkey" which should be unique.
Before appending data into appendTable I want to check if the particular pkey being appended already exists. Append data into appendTable only if pkey doesn't already exists.

Thanks
 
Something like:

use origtable order pkey
use appendtable in 0
select appendtable
append from origtable for country = "USA" ;
and not seek(appendtable.pkey, 'origtable')


Jim
 
Hi

if not used('origTable')
use origTable TAG pKey IN 0 alias OrigTable
**
endif
if not used('appendTable')
use appendTable IN 0 ALIAS appendTable
endif

IF SEEK(cPkeyValue, "origTable", "pkey")
** pkey exists .. do whatever..
** update the records
ELSE
INSERT INTO origTable (field1, field2...) ;
VALUES (field1Value, field2Value....)
INSERT INTO appendTable (field1, field2...) ;
VALUES (field1Value, field2Value....)
ENDIF

:)

ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top