|
| Iniciado por guest, 05,jul. 2017 14:09 - 9 respuestas |
| |
| | | |
|
| |
| Publicado el 05,julio 2017 - 14:09 |
Hi all,
hModify() updates a record in a file with new fieldvalues. Is there somesort of way to update one field instead of all the fields in a record ?
Best regards,
Aad |
| |
| |
| | | |
|
| | |
| |
| Publicado el 05,julio 2017 - 14:38 |
| Hi, this is standard! If you read a record with HReadSeek... then the buffer of the file is filled with values of the record. You only have to change those fields which have to be altered and then you'd issue HModify(MyFile) that's all. |
| |
| |
| | | |
|
| | |
| |
| Publicado el 05,julio 2017 - 14:39 |
Hi Aad,
to modify a record you have to read that record first after a seek or direct with hreadseek for example. Then the whole record is in a filebuffer. Then you just Need to Change your field (in the file buffer) and do hmodify.
hreadseek (file,...) file.field = new value // all other fields Keep their current values hmodify (...)
What the database Driver is doing then may not be of interest.
Erik |
| |
| |
| | | |
|
| | |
| |
| Publicado el 05,julio 2017 - 15:33 |
i was just about to post the same question.Only diffrence i am going true the wd turtorial and my understanding of databases in general is low.this bit comes from a rad patern,... so basicly i made a litle data fille (i know it would be a lot easyer just to calculated but this seemed like a good way to experiment with data filles).so
sSEARCHDATE is string sSEARCHDATE=EDT_NoName1 TABLE_Time..BrowsedItem = time.yearmonthday1..Name HReadSeekFirst(time, TABLE_Time..BrowsedItem,sSEARCHDATE , hGeneric) IF HFound(time) THEN Info(StringBuild("The search has found the following record:",...)) DateToString(time.yearmonthday1,"MM/DD/YYYY"),... time.name,... time.amount,... time.nameamount)) // Display the table from the record found TableDisplay(TABLE_Time, taCurrentFirst) END
So days/months/years discription with duplicates one unique composite key (the compleet date) i want to add the whole line however it triggers duplicate error. so is the structure of the db wrong? |
| |
| |
| | | |
|
| | |
| |
| Publicado el 05,julio 2017 - 15:47 |
Thanks guys,
The reason why I asked is, that hModify() has a potential danger. In a file with many fields it easily happens, that for some reason (planned or unplanned) another field gets a new value. then the one you want. When you are not aware of that, the file will be saved with a new value in that field. This potential danger would be history if the function hmodify(file.field) would be one of the 922 new features.
Best regards,
Aad |
| |
| |
| | | |
|
| | |
| |
| Publicado el 05,julio 2017 - 16:58 |
Hi Aad,
yes, the YearMonthDay1 item is a unique one. A second record for this day will trigger a duplicate! |
| |
| |
| | | |
|
| | |
| |
| Publicado el 05,julio 2017 - 17:02 |
To modify only one field of the file use UPDATE in sql
Create one update query or write the update by hand and run it using hexecutequery or hexecutesqlquery.
With hmodify it's always all the record. |
| |
| |
| | | |
|
| | |
| |
| Publicado el 05,julio 2017 - 17:12 |
thats just the thing
if i do time.name=a data file. or control screen to fille hmodify() and the rest of the code above
i get a duplicate error...i dont understand why i get it on description of day month year. it shouldent trigger , worst case senario the whole line should be modified instead of the strings i passed manueely,how can a duplicate trigger if i am not trying to add new line buth try to modify a line or record |
| |
| |
| | | |
|
| | |
| |
| Publicado el 05,julio 2017 - 17:20 |
Hello Aad
this is the kind of code I use in a save button (by example):
- read and block record to modify - set the values of the fields I want to modify (one or many) - do the hmodify
this way, only the fields I want are modified and I do not overwrite anything
If I don't know which fields will be modified by the user (in a file form, by example), then it's a little more complex: - when opening the form, read the record and SAVE IT in memory - when saving the form, read+lock the record again and do a triple compare, ie compare the original/saved values, the form values, and the current record. - by comparing the saved value vs the form values, I know what the user modified. By comparing the current record value vs the saved values, I know what was modified outside and I can decide what to keep
For another reason (I want to replicate only the modified fields), there is an example in WXReplication on how to find which fields were modified.
Best regards |
| |
| |
| | | |
|
| | |
| |
| Publicado el 05,julio 2017 - 17:37 |
| |
| |
| | | |
|
| | | | |
| | |
|