INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

delete some records of files

delete some records of files

(OP)
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

RE: delete some records of files

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

RE: delete some records of files

(OP)
Oups!!! I don't seen this answer.

Many thanks to "edc000"

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close