Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Buffering
Message
From
10/09/2001 09:36:21
 
 
To
10/09/2001 08:51:43
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00554518
Message ID:
00554616
Views:
7
Hi!

Add to the TABLEUPDATE(2, tlForceUpdate, "Stock_Status") (in first transaction level) a 4-th parameter - array. See help on tableupdate() command for details. Array will be populated by records failed for updating. Then process these records separately doing revert for them or just leaving as is. Child table, however, will require a separate updating loop to update one record by one as I mentioned.

BTW, it is not required to use 2 transactions here...


>Hi,
> Thank you for reply. I have the following code. I am not sure it is finr or not. Could you pls check it for me, if the way of coding is not correct...
>thank you very much
>
>
>SELECT csrTmpFile
>
>IF GETNEXTMODIFIED(0, "csrTmpFile") # 0
>	lcAdj_No = THISFORM.GetNextAdj()
>
>	IF lcAdj_No == ""
>		RETURN "NOAUTO-"
>	ENDIF
>
>	SELECT csrTmpFile
>	SCAN
>		IF csrTmpFile.AdjQty # 0
>
>			UPDATE Stock_Status SET Qty = CURVAL("Qty", "Stock_Status") + csrTmpFile.AdjQty WHERE ;
>						Stock_Status.INo = csrTmpFile.INo AND LocCode == csrTmpFile.LocCode
>
>		ENDIF
>	ENDSCAN
>	
>ELSE
>	RETURN ""
>ENDIF
>
>BEGIN TRANSACTION
>
>	IF NOT llRollBack AND NOT TABLEUPDATE(2, tlForceUpdate, "Stock_Status")
>		llRollBack = .T.
>	ENDIF
>
>	SELECT csrTmpFile
>	LOCATE
>
>	SCAN
>		SELECT Stock_Status
>		LOCATE FOR INo == csrTmpFile.INo AND LocCode == csrTmpFile.LocCode
>		IF FOUND()
>			IF AT("2", GETFLDSTATE(-1) ) = 0
>				INSERT INTO tblAdj_Details (Adj_No, INo, BCode, Qty, NewQty, AdjQty, LocCode, CPU) ;
>					VALUES (lcAdj_No, csrTmpFile.INo, csrTmpFile.BCode, csrTmpFile.Qty, ;
>							csrTmpFile.NewQty, csrTmpFile.AdjQty, csrTmpFile.LocCode, csrTmpFile.CPU)
>				lnCount = lnCount + 1
>			
>				SELECT csrTmpFile
>				DELETE
>			ENDIF
>		ENDIF
>	ENDSCAN
>
>	IF lnCount > 0
>		INSERT INTO tblStock_Adj (Adj_No, dDate, Remark, Operator) ;
>				VALUES (lcAdj_No, tdDate, tcDesc, tcOperator)
>	ENDIF
>	
>	BEGIN TRANSACTION
>
>		IF NOT llRollBack2 AND NOT TABLEUPDATE(.T., tlForceUpdate, "tblStock_Adj")
>			llRollBack2 = .T.
>		ENDIF
>
>		IF NOT llRollBack2 AND NOT TABLEUPDATE(.T., tlForceUpdate, "tblAdj_Details")
>			llRollBack2 = .T.
>		ENDIF
>
>		IF llRollBack2
>			ROLLBACK
>			ROLLBACK	&& TRANSACTION 1
>			TABLEREVERT(.T., "tblStock_Adj")
>			TABLEREVERT(.T., "tblAdj_Details")
>			TABLEREVERT(.T., "Stock_Status")
>			
>			AERROR(laError)
>			RETURN "ERROR-" + laError[2] + "(" + ALLTRIM(STR(laError[1])) + ")"
>		ELSE
>			IF llRollBack
>				AERROR(laError)
>				DO CASE
>				CASE laError[1,1] = 1585
>					RETURN "CONFLICT-"
>				OTHERWISE
>					RETURN "ERROR-" + laError[2] + "(" + ALLTRIM(STR(laError[1])) + ")"		
>				ENDCASE
>			ELSE
>				END TRANSACTION
>				END TRANSACTION		&& TRANSACTION 1
>				RETURN "SAVED-"
>			ENDIF
>		ENDIF
>
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Previous
Reply
Map
View

Click here to load this message in the networking platform