Subject Re: Append problem xdml
From Charlie <tm@tc.com>
Date Mon, 09 Nov 2020 16:10:22 -0500
Newsgroups dbase.getting-started

Oh boy...That was the wrong code.  I could never get it to work and I think you might have given me a hint why not.  The following is the code.  The loop before the append is supposed to find records not in the master table that are in the taldata table and appending a blank so there will be a matching record in master.  I think this works, but also may be causing a problem.

//used with talexp to import data into table.
        /*
        sele a
        use :train:master order PARTNO
        go top
        sele b
        use &pth2
        getname = lname
        go top
        do while not eof()
           ptn = part_no
                sele a
                //go top
                seek ptn
                //msgbox( "" + ptn )
                if eof()
                   append blank
                        replace part_no with ptn
                        //replace lname with getname
                endif
                sele b
                skip
        enddo
        */        
        //use &pth2
        //getname = lname
        use :train:taldata
        append from &pth2//+trim('temp_talname')+".dbf"
        flush


Bruce Beacham Wrote:

> Seems to be some odd coding here.
>
> On 08/11/2020 10:23, Charlie wrote:
>
> > use taldata order lname
> >         do while not eof()
> >            partno = part_no
> >                 set filter to part_no = partno
> >                 count to cnt
> >                 if cnt > 1
>
> So you are removing all records with this partno except for the last one.
>
> >                    cntr = cnt
> >                         do while cntr > 1
> >                            delete
> >                            cntr = cntr - 1
> >                         enddo
>
> The table is still pointing to the deleted record.   so you are
> recording this information on the deleted record - deliberately?
>
> >                         replace qty with cnt
> >                    set filter to
> >                 endif
> >                 skip
>
> You are now pointing to the next record after the deleted record.   At
> some point you may encounter the last record carrying the partno you
> have just reduced to one record - but its qty field could contain any
> value.
>
> But you may not encounter it:  that depends on where it lies relative to
> the rows for the partno you are now going to collapse.
>
>
> >         enddo
>
> Bruce Beacham
>
>
> > And it does add the blank correctly but it also changes somehow the size of taldata.dbf and fails when you try to run talfinis.prg.  I think it has something to do with an indexing problem.  What happens is instead of replacing all fields, only the last record in taldata is changed.  So if you add a total of 60 records in master.dbf, the last record of corresponding taldata.dbf shows a quantity of 60.  I have tried to reindex taldata.dbf but i don't think that helped.
> >
> > i'm thinking possibly I can fix this in talfinis.prg but with the set relation, i'm not sure what to do.
> >
> > If worse comes to worse i can just tell the operator of the other computer not to introduce an item not already in master.dbf.
> >
> > Sorry this is so long and probably confusing.  Just one of those stupid problems that I hope there is an easy fix for.
> >
> >
> >