Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
4
Erster Beitrag:
vor 8 Monaten, 3 Wochen
Letzter Beitrag:
vor 8 Monaten, 3 Wochen
Beteiligte Autoren:
Sivaprakash, Tor-Bjarne, GuenterP

Re: Multiple file update using hModify (WXreplication)

Startbeitrag von Sivaprakash am 01.12.2016 16: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

Antworten:

Re: Multiple file update using hModify (WXreplication)

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 ...

von GuenterP - am 01.12.2016 16:33

Re: Multiple file update using hModify (WXreplication)

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

von Sivaprakash - am 01.12.2016 18:04

Re: Multiple file update using hModify (WXreplication)

hi,


nReturn=CheckRequiredFields(sErrorMessage,sErrorField) // To check for must input fields


Do you know that you can make a field mandatory in the designer?


nReturn=DuplicateCheck(sErrorMessage,sErrorField) // To check for duplicate values


Are you searching in the same table you want to update? - then you are moving your file pointer. (Unless you are using a query in the DuplicateCheck) function.


Also why all these transactions? - When the actual record(s) are finised validation and so forth and are ready to be written to disk you should start worrying about transactions



//------------ All you validation stuff goes here
if CheckRequiredFields(sErrorMessage,sErrorField) = False or DuplicateCheck(sErrorMessage,sErrorField) = False
returntocapture(xxx)
end

// Start the transaction on the Orders and OrdLine files
HTransactionStart("C:\Temp\Transaction.trs", "Orders,OrdLine,-Customer")
Add_Order()
WHEN EXCEPTION IN
// Add the order
HAdd(Orders)
// Validate the addition
HTransactionEnd()
DO
// Delete the order lines
HTransactionCancel()
END


Cheers
Tor-Bjarne

von Tor-Bjarne - am 04.12.2016 15:39
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.