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

How to get the count of the deleted rows

Status
Not open for further replies.

sun11

Programmer
Dec 22, 2009
21
0
0
GB

Hi,

I have two tables one is oldtable which has 20000 records and other is new table .
I run the program and I am searching for the records which has more than one in the oldtable. If there is only one record I am displaying in the new table.and I am deleting from the oldtable if its been moved to the new table. The questions is if I want to know how many rows has been moved to newtable what can I do to the total count of the deleted rows in the oldtable

Thanks,
Sun11
 
Hi mikelewis,

Even when I use SELECT COUNT(*) FROM ord WHERE Deleted()
Iam not getting the count

Thanks,
Sun11
 
Have you confirmed that the records in the old table have indeed been marked as DELETED()?

If they were marked as DELETED() and then the table was PACK'd, they will not be there any longer to count.

Another thought would be the state of your SET DELETED ON/OFF

If SET DELETED ON counting DELETED() will result in 0
If SET DELETED OFF counting DELETED() will result in accurate value.

Good Luck,
JRB-Bldr
 
Sun11,

I was assuming that, when you said "deleted", you meant that they were deleted by the standard VFP way of deleting things - as opposed to a custom flag of some kind. Is that right?

Also, as JRB points out, if the table has been packed, the deleted records will no longer be present. Plus the point about SET DELETED ON.

If those assumptions are all true, you should get the count that you want.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Hi,

Do this:

"SET DELETED ON"
"COUNT FOR DELETED() TO AA"
"? AA"

"SET DELETED OFF"
"COUNT FOR DELETED() TO AA"
"? AA"

Verify the value of AA on your screen to see which gives the result you want. If both results of AA give you 0 (zero) then there are no deleted records in your dbf.

Simple and clear.


Thanks,
M7


 
I like doing it this way, as the "Count to" will move the record in the table, while the select *, won't affect that.

oDel = Set("Deleted")
Set deleted off
Select Count(*) as DelRecords ;
From myTable ;
where Deleted() ;
into cursor _curDeleted

Set deleted &oDel
?nvl(_curDeleted.DelRecords,0)
use in select("_curDeleted")

Ali Koumaiha
TeknoSoft Inc.
Michigan
 
select count(*) from mytable where not deleted() into array myarray

lnDeleted=reccount([myTable])-myArray[1]

I like this because you do not need to worry about any external setting.



Alan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top