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!

delete some records of files

Status
Not open for further replies.

berthoud

Technical User
Oct 31, 2010
51
FR
Hello every body,

I have a file FACTURES (with a field FAC:Fact_ID and his key FAC:K_FactID) and a second (child) LIGNES (with a field LIG:Fact_ID and his key LIG:K_FactID).

I have a form for create FACTURES records and in this form a browse of LIGNES records (with controls for add/edit/delete records)

If I cancelled FACTURES creating, after adding LIGNES records, I need to delete these records of LIGNES wich have the value of LIG:Fact_ID.

I do this code in close windows embed

Code:
LIG:Fact_ID = FAC:Fact_ID (for exemple = 2)
set(LIG:K_FactID,LIG:K_FactID)
clear(LIG:Fact_ID)
next(lignes)
loop while LIG:Fact_ID = FAC:Fact_ID
    delete(lignes)
    clear(lig:record)
    next(lignes)
end

This code works well in an old application (my first with clarion, writen there is 15 years ago), but in the new one I have troubles.

for example : if I have 4 records in LIGNES where LIG:Fact_ID = 2, the first time the code is executed (just after created records), only the last record is deleted.
The second time all 3 records are well deleted.

I think, the first time, my code don't read the fisrt record, but the last one. Why? How I could do to be sure I read the first one
Have you some idea?

Many thanks

Have a good day
 
I use to delete:

stream(lignes)
LIG:Fact_ID = FAC:Fact_ID
set(LIG:K_FactID,LIG:K_FactID)
loop
next(lignes)
if errorcode() or LIG:Fact_ID <> FAC:Fact_ID then break.
relate:lignes.delete(0)
end
flush(lignes)

and use for clear:

stream(lignes)
LIG:Fact_ID = FAC:Fact_ID
set(LIG:K_FactID,LIG:K_FactID)
loop
next(lignes)
if errorcode() or LIG:Fact_ID <> FAC:Fact_ID then break.
clear(LIG:record)
access:lignes.update()
end
flush(lignes)

I hope that good for you! bye
 
Oups!!! I don't seen this answer.

Many thanks to "edc000
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top