Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Why not deleting?
Message
De
12/10/1999 16:47:16
 
 
À
11/10/1999 15:52:42
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00274937
Message ID:
00275617
Vues:
20
>>>>>>>Sorry, I did not mean for you to discard the LOCATE command.
>>>>>>>select gisum (parent)
>>>>>>>replace lc_action with "D"
>>>>>>>dele
>>>>>>>currec= recno()
>>>>>>>csessionkey = gisum.sessionkey
>>>>>>>Select gidetail
>>>>>>>LOCATE for gidetail.sessionkey = csessionkey
>>>>>>>if !eof()
>>>>>>>   lnDelrec= recno()
>>>>>>>   replace gidetail.lc_action with "D" while gidetail.sessionkey = csessionkey
>>>>>>>   goto lnDelrec
>>>>>>>   delete while gidetail.sessionkey = csessionkey
>>>>>>>endif
>>>>>>>go currec
>>>>>>
>>>>>>
>>>>>>Hi Mark:
>>>>>>
>>>>>>Still not working for me...it's skipping over the records that
>>>>>>match the sessionkey and not deleting them
>>>>>
>>>>>I made an assumption that the child table has the index set to the SessionKey field. This allows for quicker deletion using the WHILE clause instead of FOR. The FOR will scan all records. WHILE will do a Replace, Delete, etc., while that field is equal to the variable. Did you by chance open the child table/view using the NoUpdate clause or in some other way make the table/view read-only?
>>>>>
>>>>>Also, if the table is ordered by SessionKey, the LOCATE can be changed to a SEEK. Otherwise, the code above should now work if you do not have a SET FILTER TO LC_ACTION <> "D". Do the child records at least show that field getting changed to "D"?
>>>>
>>>>HI:
>>>>
>>>>I just don't know what's happening here...
>>>>i just tried deleting child records first but still only deleted parent.
>>>>
>>>>My code is now:
>>>>
>>>>Select gisum
>>>>csessionkey= gisum.sessionkey
>>>>
>>>>select gidetail
>>>>seek(csessionkey)
>>>>if found()
>>>> if !eof()
>>>> lndelrec =recno()
>>>> replace lc_action with "D"
>>>> goto lndelrec
>>>> dele all while getail.sessionkey=csessionkey
>>>>endif
>>>>endif
>>>>
>>>>I have no filters on the tables, there is primary key on gisum - sessionkey
>>>>regular index on gidetail - sessionkey,(both tagged sessionkey) it finds the matching sessionkey
>>>>shows through the debugger that it's replacing, goto lndelrec skips over
>>>>the records i want to delete. When I check the dbf afterwards, no change to Lc_action(No d"S) and records not deleted.
>>>>
>>>>Fred was mentioning earlier that skipping could be caused by a replace statement.
>>>>When I append blank in Gidetail - i do a replace gisum.sessionkey with
>>>>gidetail.sessionkey.
>>>>
>>>>I'm stumped!!
>>>
>>>
>>>Even when you step through with the debugger, you should see the "D" being replaced in your field, and then the record should get deleted. What is the current state of SET('DELETED), just before you try to replace the "D" in lc_action?
>>
>>Hi Fred:
>>
>>It's not replacing my field as I thought through the debugger, also my set deleted is on. It doesn't execute the replace statement?
>
>
>If the currently selected alias is at EOF(), then no, the replace doesn't happen. Try doing a "REPLACE ... IN gidetail" and see if THAT works.


Hi:

Just wanted to say thanks for your input and assistance...and patience!

Hard to believe a delete would be so difficult,

I got it working later yesterday....with a for loop and delete next 1,
it wouldn't do a delete with delete all.

Anyway, thanks again.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform