PC SOFT

PROFESSIONAL NEWSGROUPS
WINDEVWEBDEV and WINDEV Mobile

Home → WINDEV 2024 → HModify and MySQL
HModify and MySQL
Started by David, Aug., 26 2004 1:07 PM - 5 replies
Posted on August, 26 2004 - 1:07 PM
I have a form linked to a MySQL table with this structure:
CustomerID is int(3) //Unique
CustomerName is char(40) //Index
CustomerBI is char(10)
...
I use HReadFirst, HReadPrevious and HReadNext functions to browse the records and they work fine, but i don't know why the HModify function don't work with the browsed field:
HReadFirst(customer, CustomerName)
ScreenToFile() // changing values
HModify (customer)
All fields are modified except the browsed one in this case is CustomerName.
If i use a SQLquery to update the CustomerName Windev brings up a Window saying that the record was modified by other user and asks what to do.
Does anyone knows why this happen and how can i force the Hmodify function to update the field?
Thanks for your pacience to read all this and bother to answer!!
Posted on August, 26 2004 - 5:39 PM
Hi David,
you have to understand that HreadFirst / HreadNext are working on a file pointer. This pointer points to the current record - according to the key field that you are using for traversing the file. By modifying that key you destroy the pointer because it's pointing to nowhere after HModify and consquently, you'd receive an error. So, if you want to modify all of your key fields while doing the HReadFirst / HReadNext thing, you have to use some other non-key field for browsing, which is possible(?), according to the docs. I Never tried to do so and I suspect, the reading will be much slower than using a key item.
Guenter
I have a form linked to a MySQL table with this structure:
CustomerID is int(3) //Unique
CustomerName is char(40) //Index
CustomerBI is char(10)
...
I use HReadFirst, HReadPrevious and HReadNext functions to browse the records and they work fine, but i don't know why the HModify function don't work with the browsed field:
HReadFirst(customer, CustomerName)
ScreenToFile() // changing values
HModify (customer)
All fields are modified except the browsed one in this case is CustomerName.
If i use a SQLquery to update the CustomerName Windev brings up a Window saying that the record was modified by other user and asks what to do.
Does anyone knows why this happen and how can i force the Hmodify function to update the field?
Thanks for your pacience to read all this and bother to answer!!
Posted on August, 26 2004 - 6:23 PM
Thanks Guenter, but is there a workaround??!
If i understood your explanation the browsing functions create a lock on the browsed field, is it possible to unlock it made the updates and return to the same record? Please note that this file will always be small 1000 records top.
The only objective is to browse the file in alphabetic order so I use the CustomerName field in browsing functions (ex: HReadFirst(customer, CustomerName)).
Thanks once again
Hi David,
you have to understand that HreadFirst / HreadNext are working on a file pointer. This pointer points to the current record - according to the key field that you are using for traversing the file. By modifying that key you destroy the pointer because it's pointing to nowhere after HModify and consquently, you'd receive an error. So, if you want to modify all of your key fields while doing the HReadFirst / HReadNext thing, you have to use some other non-key field for browsing, which is possible(?), according to the docs. I Never tried to do so and I suspect, the reading will be much slower than using a key item.
Guenter
Posted on August, 26 2004 - 7:13 PM
Hi David,
I don't think that you can speak of a lock-situation.
You can try after execute the HModify to execute a HChangeKey on the (changed) name-key. I suppose you can browse after that.
Regards, Stefan.
Thanks Guenter, but is there a workaround??!
If i understood your explanation the browsing functions create a lock on the browsed field, is it possible to unlock it made the updates and return to the same record? Please note that this file will always be small 1000 records top.
The only objective is to browse the file in alphabetic order so I use the CustomerName field in browsing functions (ex: HReadFirst(customer, CustomerName)).
Thanks once again
Hi David,
you have to understand that HreadFirst / HreadNext are working on a file pointer. This pointer points to the current record - according to the key field that you are using for traversing the file. By modifying that key you destroy the pointer because it's pointing to nowhere after HModify and consquently, you'd receive an error. So, if you want to modify all of your key fields while doing the HReadFirst / HReadNext thing, you have to use some other non-key field for browsing, which is possible(?), according to the docs. I Never tried to do so and I suspect, the reading will be much slower than using a key item.
Guenter
Posted on August, 26 2004 - 10:04 PM
Hi Stefan,
one should test, whether a HChangeKey operation can be done at all to the same key/record. But if, there is no protection against the possibility that you generate a 'hole' in the stepping sequence through the file. As well it's possible this way to set the file pointer back into the midst of already browsed records.
Way out / around: Make a new (second) file and write the changed records there. After writing the second file copy that over the original file. That's it.
Best regards,
Guenter
Hi David,
I don't think that you can speak of a lock-situation.
You can try after execute the HModify to execute a HChangeKey on the (changed) name-key. I suppose you can browse after that.
Regards, Stefan.
Thanks Guenter, but is there a workaround??!
If i understood your explanation the browsing functions create a lock on the browsed field, is it possible to unlock it made the updates and return to the same record? Please note that this file will always be small 1000 records top.
The only objective is to browse the file in alphabetic order so I use the CustomerName field in browsing functions (ex: HReadFirst(customer, CustomerName)).
Thanks once again
Hi David,
you have to understand that HreadFirst / HreadNext are working on a file pointer. This pointer points to the current record - according to the key field that you are using for traversing the file. By modifying that key you destroy the pointer because it's pointing to nowhere after HModify and consquently, you'd receive an error. So, if you want to modify all of your key fields while doing the HReadFirst / HReadNext thing, you have to use some other non-key field for browsing, which is possible(?), according to the docs. I Never tried to do so and I suspect, the reading will be much slower than using a key item.
Guenter
Posted on August, 27 2004 - 2:48 AM
G'day David
As the file is not that big you could use a memory table instead with no performance loss and then update the file on RowExit if the customer name has changed.
Regards
Al