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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting RECALLed records. 1

Status
Not open for further replies.

mmerlinn

Programmer
May 20, 2005
748
US
I RECALLed the deleted records in table #1 in error. Now I want to DELETE those records and am at a loss at how to structure the DELETE.

Within table #1 there is no commonality distinguishing the valid records from the invalid records.

However, every invalid record in table #1 has a part number that does not exist in table #2 while every valid record does have a corresponding part number in table #2. So, what I need to do is to structure the DELETE to DELETE only those records in table #1 that do not have a corresponding part number in table #2.

How do I do that?

mmerlinn


Poor people do not hire employees. If you soak the rich, who are you going to work for?

"We've found by experience that people who are careless and sloppy writers are usually also careless and sloppy at thinking and coding. Answering questions for careless and sloppy thinkers is not rewarding." - Eric Raymond
 
DELETE only those records in table #1 that do not have a corresponding part number in table #2.

Code:
USE Table2 IN 0 EXCL
SELECT Table2
* --- If Index Does Not Already Exist ---
INDEX ON PartNo TAG PartNo
* --- Set Index ACTIVE ---
SET ORDER TO PartNo

USE Table1 IN 0 EXCL
* --- Set Relation on PartNo Into Table2 ---
SELECT Table1
SET RELATION TO PartNo INTO Table2
* --- Delete where nothing exists in Table2 ---
DELETE FOR EMPTY(Table2.PartNo)

Once that is done you can PACK Table1 if you want to do so and totally Remove the records 'flagged' for Delete.

NOTE - before you do the DELETE you might want to do a
BROWSE FOR EMPTY(Table2.PartNo) to visually confirm that the records you want are those which will be affected.

Good Luck,
JRB-Bldr

 
[tt]jrbbldr[/tt]

Perfect. Worked like a charm.

The only thing I needed to modify was the SCOPE from NEXT 1 to ALL.

Yes, I made a copy of the tables before I tried this.

Yes, I could have played around and found the solution myself.
However, when deleting anything, I would rather be safe than sorry.

Thanks. And a star for your prompt correct answer.

P.S. I tried replying using FF on my Mac, but there were no SUBMIT
nor PREVIEW buttons anywhere on the webpage.

mmerlinn


Poor people do not hire employees. If you soak the rich, who are you going to work for?

"We've found by experience that people who are careless and sloppy writers are usually also careless and sloppy at thinking and coding. Answering questions for careless and sloppy thinkers is not rewarding." - Eric Raymond
 
I tried replying using FF on my Mac, but there were no SUBMIT nor PREVIEW buttons anywhere on the webpage.

I'll report it to the Tek-Tips gurus.

JRB-Bldr

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top