PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → Shared access on datafiles?
Shared access on datafiles?
Iniciado por guest, 09,may. 2015 17:56 - 3 respuestas
Publicado el 09,mayo 2015 - 17:56
I try to explain the issue with directly with an example.
A project contains 2 forms, master-detail, for browsing customers for example.
The main form shows the whole list of customers and the user can open the detail for N customers. So an user can open via OpenChild N detail form concurrently, customer1 + customer2 + customer3 (eventually more than one instance of customer1 but only for testing purpose).

If each detail form uses a HReadSeekFirst on Customer datafile + FileToScreen to retrieve data and filling form fields it seems that the 3 instances of detail form share the access to the datafile. So if I click a debug button for showing the value of Customer.name and the forms are opened in sequence 1-2-3 when i show the value on form1 after form3 is loaded I see the name of customer3 because the last read on the file has been performed by form3.

Even if I open a detail form while the master form is still loading the big list of customers It seems that the HReadSeekFirst of detail form could be in conflict with the HReadNext of the master form.

I expected that each form has its own access/flow on the datafile but tests gave me another response. It seems that N processes launched on the same datafile from the project analysis steal each other the current cursor to the datafile. How to get rid of this?
Aliases are not a solution for me because I cannot use them to link data to controls at design time. Opening several parallel connections to the database is the only choice?

I'm a novice so I hope this happens due to my inexperience on WD.
Thank you
Publicado el 09,mayo 2015 - 18:27
Hi, the key to understanding your problem is the so-called 'HyperFile context' which you can find in the 'Details' Tab of each window. If both of your windows do have an 'independent' HyperFile context then these windows can navigate the same file independently, means, one of them can show customer A and the other one customer B. If Window 1 opens Window 2 then the HyperFile context of Window 1 will be copied to Window 2! From there on, Window 2 is independent of Window 1! The HyperFile context contains a lot of information for each of the open files in each window (see: http://help.windev.com/en-US/… ) among those is the file pointer which points to the current record in the file. If you want to independently access the same file twice in a window then you have to make an alias (see: <a class="ExternalLink" rel="nofollow" target="_blank" href="http://help.windev.com/en-US/?3044176&name=HAlias">http://help.windev.com/en-US/&hellip;</a> ) of that file. If there is no 'independent HyperFile context' (checkbox not checked) then Window 2 relies on the HyperFile context of Window 1, which opened Window 2.
Publicado el 10,mayo 2015 - 00:01
Good news.. this is exactly what I mean. The bad news is that I use Analysis + H functions with the HF engine connected to MySql via Native Access and it seems from what I just read on the link you posted that Native Access for MySQL does not fully support independent context..

I have to clarifiy

The "Independent HFSQL context" option is not supported by the following databases:
Native Informix Access
Native DB2 Access
Native MySQL Access
Native PostgreSQL Access
Native SQLite Access
Native xBase Access
Native XML Access
Any database via OLE DB (or ODBC via OLE DB)

and the second note
Notes:
From the global code of an MDI parent window, you cannot access a query run in a child window with an independent HFSQL context, even if the data source used is global to the project.
All the Native Accesses support the independent HFSQL contexts. However, the copy of context is not supported by some Native Accesses: you have the ability to start and perform a browse in the independent contexts. But you cannot continue in a new context a browse started in a first context.

that seems to be in contrast with the first statement
Publicado el 10,mayo 2015 - 00:49
I tried a little on the fly and it seems that what I need is supported on MySql. If I open Form2 it takes its context and Form1 is not affected from the last read on the same datafile performed by Form2 anymore.

The "Independent HFSQL context" option is not supported by the following databases
I checked the flag and it behaves differently as the second note says
All the Native Accesses support the independent HFSQL contexts.

However, the copy of context is not supported by some Native Accesses: you have the ability to start and perform a browse in the independent contexts. But you cannot continue in a new context a browse started in a first context.
If it is so, it's ok.. why shoud I resume a browse started on the main form into a child or sister form?!? If only this is not supported, really don't care... I missed something important?

Combining independent context, query by hand and the Record new variable type given by my WD20 I have all I need. Really I still have to figure out what Record type actually has more than the old Data Source type...

Thank you for the advice.