|
| Re: Multiple file update using hModify (WXreplication) |
| Iniciado por guest, 01,dic. 2016 17:08 - 2 respuestas |
| |
| | | |
|
| |
| Publicado el 01,diciembre 2016 - 17:08 |
Hello,
Using: Windev 21, HFSQL 21
I get error when I try to update multiple files from the same screen. It works fine when updating both files, first time. When run for the second time, it gives error. I try to update one record from 'state' file and multiple records from 'district' file.
The HFSQL file or link named 'AliasState' is unknown.
@ line no. 34 of method MakeRecordContent process.
All gets updated for the first time, in the second run, it fails while updating the 'state' file itself.
Any thing I'm missing ? Any help ?
Happiness Always BKR Sivaprakash |
| |
| |
| | | |
|
| | |
| |
| Publicado el 01,diciembre 2016 - 17:33 |
Hi, yes, something's missing indeed: 1 - the code which you tell us gives an error and 2 - you don't tell us which error.
Imho, you don't do an HReadNext, an HReadseek or any repositioning of the file pointer before trying to update the next record. But that's only a guess since you supply happiness without facts supporting your request ... |
| |
| |
| | | |
|
| | |
| |
| Publicado el 01,diciembre 2016 - 19:04 |
GuenterP,
Here is the code // in Save Button nReturn is int sErrorMessage is string ="" sErrorField is string ="" bTransaction is boolean=False
nReturn=CheckRequiredFields(sErrorMessage,sErrorField) // To check for must input fields IF nReturn=0 THEN // found an incomplete field ToastDisplay("You haven't filled all the fields",toastLong, vaMiddle, haCenter) ReturnToCapture({sErrorField}) END
nReturn=DuplicateCheck(sErrorMessage,sErrorField) // To check for duplicate values IF nReturn = 0 THEN // found an duplicate field ToastDisplay(sErrorMessage,toastLong, vaMiddle, haCenter) ReturnToCapture({sErrorField}) END
nReturn = CheckInactiveValues(sErrorMessage, sErrorField) // To check for inactive Country IF nReturn=0 THEN // found inactive country selected ToastDisplay(sErrorMessage, toastLong, vaMiddle, haCenter) ReturnToCapture({sErrorField}) END
// transfer screen data to the record structure ScreenToSource()
HOnError("*",hErrAll,"") IF HTransactionStart(ClassicDatabaseTRS) = False THEN sErrorMessage="problem starting the transaction ..." bTransaction = False Info(sErrorMessage) ELSE bTransaction = True END
IF bTransaction = True THEN IF HReadSeekFirst(State,usGUIDState, r_State.usGUIDState) = False THEN // Navigating to the record, to update sErrorMessage = "State record not found" + r_State.usGUIDState bTransaction = False Info(sErrorMessage) ELSE bTransaction = True END END
IF bTransaction = True THEN State.bNotActive = r_State.bNotActive // Just modifying one field IF hModify(State) = False THEN sErrorMessage = gpoDB.GetErrorInfo() bTransaction = False ELSE bTransaction = True END END
IF bTransaction = True THEN FOR EACH District WHERE sStateFK = r_State.usGUIDState District.bNotActive = State.bNotActive IF hModify(District) = False THEN sErrorMessage = gpoDB.GetErrorInfo() bTransaction = False END END END
IF bTransaction=False THEN HTransactionCancel() Error(sErrorMessage)) ReturnToCapture(EDT_State) ELSE HTransactionEnd() END
// Error Error at line 35 of Method MakeRecordContent process The HFSQL file or link named 'AliasState' is unkown.
////////////////////////////////////////////////////
The above code works fine when I update the state for the first time. GetAlias function, available in WXReplication, is storing the aliasname in an array. When I try to update the same file second time, that function returns the alias name from the array, then I get the above error.
Don't have problem in updating one file. Don't know whether it's the right way to call to update two files within transaction. /////////////////////////////////////////////////////
To test, I created one procedure which will accept a state name, modify that state and all districts under that state. This is for testing purpose only. It modified all 4 states, corresponding districts without any problem.
sErrorMessage is string ="" bTransaction is boolean=False
HOnError("*",hErrAll,"")
IF HTransactionStart(ClassicDatabaseTRS)=False THEN sErrorMessage="problem starting the transaction ..." RESULT False END
bTransaction = SP_SetupStates(sErrorMessage) // Creating default states.... IF bTransaction=False THEN HTransactionCancel() ELSE HTransactionEnd() END
SP_SetupDistricts() // Creating default districts ...
bTransaction = SP_StateModify("Andhra Pradesh", sErrorMessage) // Procedure to modify one state and its corresponding districts. IF bTransaction=False THEN Info("Update failed for andhra pradesh" + sErrorMessage) HTransactionCancel() ELSE Info("update success for andhra pradesh") HTransactionEnd() END
bTransaction = SP_StateModify("Assam", sErrorMessage) IF bTransaction=False THEN Info("Update failed for assam" + sErrorMessage) HTransactionCancel() ELSE Info("update success for assam") HTransactionEnd() END
bTransaction = SP_StateModify("Bihar", sErrorMessage) IF bTransaction=False THEN Info("Update failed for Bihar" + sErrorMessage) HTransactionCancel() ELSE Info("update success for Bihar") HTransactionEnd() END
bTransaction = SP_StateModify("Gujarat", sErrorMessage) IF bTransaction=False THEN Info("Update failed for Gujarat" + sErrorMessage) HTransactionCancel() ELSE Info("update success for Gujarat") HTransactionEnd() END
Couldn't figure out where the problem lies. Any help to figure out is really appreciated.
Happiness Always BKR Sivaprakash |
| |
| |
| | | |
|
| | | | |
| | |
|