Deleting MV rows (OpenInsight Specific)
At 07 SEP 2001 09:30:01AM a becker wrote:
I am doing a programmatically mass delete in which an MV entry, upon meeting the requirements, is to be deleted. If I was displaying this on a form and having the user deleted a particular row in the EDITTABLE it would be no problem. However, it appears that the Delete and Delete_Row will delete the entire record. What command can I use to use delete the entry that meets the criteria?
Example
entry 1 - doesn't meet criteria
entry 2 - meets criteria
entry 3 - doesn't meet criteria
end of entries
When finished I want:
Entry 1 - left as is
Entry 2 - this was entry 3, the original entry 2 has been deleted
end of entries.
I know I can move the entries around individually, that just takes some coding.
Any ideas?
Thanks for your help
Andy Becker
Il. State Lottery
and No - I don't know what the numbers are - If I did I wouldn't be working - ;)
At 07 SEP 2001 01:50PM Oystein Reigem wrote:
Andy,
I don't know of any command that can do what you want. You need to write a program to do this.
Btw - what happens if all the MV values of a record meet the deletion criteria? Should the record itself go too?
- Oystein -
At 07 SEP 2001 02:03PM Oystein Reigem wrote:
Andy,
That program should go something like this. I've here assumed you don't want to delete a whole record, even if all its MV values are deleted:
open the table
clearselect cursors
select the table. or use select by if you need to process the records in a particular order
loop while not done
. readnext key then
. . read record then
. . . get the MV field and loop through the values, deleting the ones that meet the criteria. update the record with the altered MV data
. . . write the record back else
. . . . error handling
. . . end
. . end else
. . . error handling
. . end
. end else
. . you're done
. end
repeat
update the index for the MV field if there is one
- Oystein -
At 10 SEP 2001 07:46AM Colin Rule wrote:
In addition to the other points, make sure any loop through the MVs is in reverse order.
For example, dont use
FOR MV=1 to MVCOUNT
ITEM=DELETE(ITEM,1,MV,0)ITEM=DELETE(ITEM,2,MV,0)ITEM=DELETE(ITEM,3,MV,0)NEXT MV
But use
FOR MV=MVCOUNT TO 1 STEP -1
ITEM=DELETE(ITEM,1,MV,0)ITEM=DELETE(ITEM,2,MV,0)ITEM=DELETE(ITEM,3,MV,0)NEXT MV
If you use the first example, and find a match on MV 1, then delete it, then it increments the pointer to 2, the MVs have moved up and you may miss a test to delete.
Starting at the end always ensures it does the job properly.
Colin
At 10 SEP 2001 09:27AM a becker wrote:
Yes Oystein, if all the MVs are removed, the entire record is deleted. I was hoping there was a command that would just delete, programmatically, the selected occurrence, but oh well, it's time to get down to doing it the hard way. At least this way, I'll have control over it.
Thanks
Andy
At 10 SEP 2001 09:36AM a becker wrote:
Thanks for the input, Colin. I was experimenting last week and discovered that I would have a problem. I was wondering what I could do to work around this bug, and, thanks to you, you gave me the answer.
Thanks
Andy