Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
14
Erster Beitrag:
vor 5 Monaten, 3 Wochen
Letzter Beitrag:
vor 5 Monaten, 1 Woche
Beteiligte Autoren:
Marijan Tomasic, Alen U., Frans, Harry W, ICI

[WD18] DBF merge files problem (or Native Access problem?)

Startbeitrag von Marijan Tomasic am 22.02.2017 08:03

Hello!

I have a very bizarre problem when merging two DBF files from old VFP DOS program. (adding records from one file to another)

Appending records from items2.dbf in items1.dbf file, and from headers2.dbf in headers1.dbf file. The resulting files are not the same as when using a DBF utility for this purpose. The resulting files have the appropriate number of records, the appropriate number of crossed records and so on. But when I put the resulting files in the original VFP DOS program, which works summarizing certain columns and values, do not get the appropriate results.

Here's the last version of code for items file (same is used for headers):

HReadFirst(items2, hForwardOnly+hNoRefresh+hLockNo)
WHILE NOT HOut(items2)
HCopyRecord(items1,items2)
HAdd(items1)
HReadNext(items2,hLockNo)
END

Items1 and items2 have identical structure, and also headers1 and headers2.
Any ideas where he might be the problem? I experimented with different ways to add records, but always the same problem occurs.

Antworten:

Re: [WD18] DBF merge files problem (adding records from one file to another)

Hi Marijan

Maybe you can try to create Query's on your files and execute query's with constant
"hModifyFile". Then you can try to copy records

FOR EACH Items2
hCopyRecord(items1,items2)
hAdd(items1)
END

von ICI - am 22.02.2017 09:10

Re: [WD18] DBF merge files problem (adding records from one file to another)

Hi,
you probably have some indexes in VFP program and that indexes are not updated with your code. So without index you see all records but with opened (not updated) index VFP see only indexed records.

Hope it helps.

BR
Alen

von Alen U. - am 22.02.2017 18:05

Re: [WD18] DBF merge files problem (adding records from one file to another)

ICI and Alen, thank you very much for the help.

I'm still occupied solving this problem.

I found that import DBF files with CDX indexes does not work well. It is possible to import only indexes with a single order, and not with multiple order in a CDX file. Also, it is impossible to import the index if the order name the same as the name of a field in the file (VFP allows it). So I tried not to use indexes.

Anyway, it does not solve my problem. It is strange that the expected number of records in the final DBF file is good, but the result of calculations from the original program is not correct. Original VFP program has the option to restore the index, but it does not solve the problem.

von Marijan Tomasic - am 24.02.2017 06:26

Re: [WD18] DBF merge files problem (adding records from one file to another)

I do not understand how this is possible?

HNbRec(z1,hStateAll) = 9938 records
HNbRec(z1,hStateActive) = 9938 records
HNbRec(z1,hStateCrossed) = 15 records
HNbRec(z1,hStateDel) = 15 records


Now I see it is corect for xBase files...

von Marijan Tomasic - am 24.02.2017 07:52

Re: [WD18] DBF merge files problem (adding records from one file to another)

Hi,

What is your goal ?

Just extracting the data from DBase and replace it into another database like HFCS or MSSQL ?
Then you can can export DBase to a txt file an read it back into the database you want.

Maybe not so clean but easy to do...

Regards, Harry

von Harry W - am 24.02.2017 12:54

Re: [WD18] DBF merge files problem (adding records from one file to another)

Finally I found where the problem is, but not why it happened. It seems to me that there is a bug in the function HCopyRecord. Some values of logical fields are not correct in the copied records. See the attached picture, the columns with "T" and "F" values ...

The image above shows the original records, and in the image below these same records after copying.

[attachment 2297 maybe_bug.png]

von Marijan Tomasic - am 06.03.2017 08:16

Re: [WD18] DBF merge files problem (SOLVED)

I finally solved the problem.

In the Analysis I added the default value of "F" for all logical fields from DBF (imported as Text).
After that, everything worked as expected.

von Marijan Tomasic - am 06.03.2017 11:44

Re: [WD18] DBF merge files problem

Unfortunately, the problem is not solved. Hasty I believe that I have succeeded.

I spent too much time on this trivial task. It is obvious that there is a bug when copying a logical entry fields with DBF files. I wasted all the time saved by 10 times faster development. :) I give up.

Maybe someone has the will to try merging DBF files containing logical fields in the record.

von Marijan Tomasic - am 07.03.2017 10:57

Re: [WD18] DBF merge files problem

Hello Marijan,

Try the help from Fabrice. He works remotely with you on your computer.
It wil cost you a few dollars but can save you an enormous amount off time.

Regards Frans

von Frans - am 07.03.2017 11:05

Re: [WD18] DBF merge files problem

It seems that native DBF access does not read properly logical values.
Please check the columns that contain the logical values (STORNO, AZUR, OBAVIJEST)!

this is test.dbf opened with dbx utility (logical values are correct):
[attachment 2300 test-dbx.png]

this is the same test.dbf opened with wdmap (logical values are NOT correct):
[attachment 2301 test-wdmap.png]

here is original test.dbf file (please first remove rtf extension):
[attachment 2302 test.dbf.rtf]

von Marijan Tomasic - am 07.03.2017 12:21

Re: [WD18] DBF merge files problem

Hi,
it looks that WDMAP v21 works ok (picture attached)

BR,
Alen
[attachment 2303 Capture.PNG]

von Alen U. - am 07.03.2017 12:41
Hi,
just checked other versions.

V18 doesn't work ok, but from V19-21 works ok.

BR,
Alen

von Alen U. - am 07.03.2017 12:46
Thanks Alen!

von Marijan Tomasic - am 07.03.2017 13:20
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.