Subject Re: xdml append from problem
From Charlie <tm@tc.com>
Date Thu, 29 Aug 2024 10:04:48 -0400
Newsgroups dbase.getting-started

Thanks for the info Akshat...

I have since done some work on this in making sure the field names match the table i am trying to append to.  I also now have them in the exact order.  But the append to table has 5 fields extra which are at the end of the table.  Is it possible that I have to add 5 blank fields with headers to the append from table?  I don't think that is the case but i could be wrong.


Akshat Kapoor Wrote:

> Good Morning Charlie,
>
> > I know this is dated but I am having a problem with the append from statement.  It seems to only append one record.  The append is at the bottom of the code.  I am wondering if possibly the code i am using toward the top from mervyn might be affecting this somehow.
> >
> > Your code works perfect Mervyn but i am wondering if it could be affecting append.  Or possibly I am making a stupid error of some kind.
> >
> > Any help will be very much appreciated.
> >
> >       set procedure to append_from_csv.prg
> >         try
> >        append_from_csv(_app.folder3+'csvrec.dbf','&pth1','d',true)
> >     catch (exception e)
> >            msgbox( "Abort import.  File must be CSV format with correct 12 columns." )
> >                 return
> >     endtry
> >         use csvrec
> >         count to cnt
> >         if cnt < 1
> >            msgbox( "There there are 0 rows.  Cannot proceed." )
> >                 return
> >         endif
> >     msgbox( "CSV file successfully imported." )
> > else
> >     msgbox( "Import aborted." )
> > endif
> > set filter to
> > use csvrec
>
> I have not used this piece of code so will not comment on that but I
> would check the number of rows appended here before deleting any rows.
> my xdml is a slightly rusty so check for errors.
>
> Count all to temp
> ?temp, [rows in the table]
> > delete for empty(id) or empty(country)
> > replace all id with upper(id)
> > replace all category with upper(category)
> > replace all grade with upper(grade)
> > replace all location with upper(location)
> > replace all country with upper(country)
> > replace all metal with upper(metal)
> > replace all mintage with upper(mintage)
> > replace all details with upper(details)
> > sele a
> > use memo
> > nsk = newsku
> > sele b
> > use country
> > sele c
> > use collection
> > go top
> > append from :coindata:csvrec.dbf// for not empty(id)
> >  
> > I tested this with a message box and it always indicates one record was appended ( out of 13) on my last try.
>
> It might be possible that rows are getting appended but with some
> incorrect value and are getting deleted.
>
> Regards
> Akshat