of_endtran


pfcapsrv.pbl   >   pfc_n_cst_luw   >   of_endtran   

Full name pfc_n_cst_luw.of_endtran
Access public
Extend of integer
Return value integer
Prototype public function integer of_endtran(n_tr[],integer)

Name Datatype
No Data

Name Datatype
li_cnt Integer
li_i Integer
li_idx Integer
li_max Integer
li_rc Integer
li_secondaryrc integer[]
ltr_performed n_tr[]
ltr_secondary n_tr[]

public function integer of_endtran (n_tr atr_control[], integer ai_saverc);//////////////////////////////////////////////////////////////////////////////
//
//	Function:  of_EndTran
//
//	Access:  Public
//
//	Arguments:
//	atr_control[]   Array of controls to End Transactions on.
// ai_saverc		The current Save Return code used to determine how to end
//						the transaction.
//
//	Returns:  integer
//	 1 = Ending of Transaction(s) were successful, no errors found
//	-1 = An error was found
//
//	Description:
//	End Transaction(s) on all the Transaction Objects.  Depending on the save
//	return code, the transaction is either committed or rollback.
//
// Note:
//	This function assumes that all transaction passed in currently have a 
// transaction to be ended.
//
//////////////////////////////////////////////////////////////////////////////
//	
//	Revision History
//
//	Version
//	6.0   Initial version
//
//////////////////////////////////////////////////////////////////////////////
//
//	Copyright © 1996-1997 Sybase, Inc. and its subsidiaries.  All rights reserved.
//	Any distribution of the PowerBuilder Foundation Classes (PFC)
//	source code by other than Sybase, Inc. and its subsidiaries is prohibited.
//
//////////////////////////////////////////////////////////////////////////////

Integer	li_rc
Integer 	li_max
Integer 	li_i
Integer	li_idx
Integer	li_cnt = 0
n_tr		ltr_performed[]
n_tr		ltr_secondary[]
integer	li_secondaryrc[]

// Validate the argument.
If IsNull(atr_control) Then
	Return -1
End If

// If requested use the assist funtionality.
If ib_assist Then 
	of_Assist(is_instancename+'.of_EndTran('+of_GetClassNames(atr_control)+ &
		', '+String(ai_saverc)+')')
End If

// Loop around all transactions objects, Begining a new Transaction.
li_max = UpperBound(atr_control)
For li_i = 1 to li_max
	If ai_saverc > 0 Then
		If atr_control[li_i].of_Commit() < 0 Then
			// -- An error committing a transaction has been encountered. --			
			
			// Loop around Uncommitted transactions.
			li_cnt = 0
			For li_idx = li_i to li_max
				// Rollback.
				li_rc = atr_control[li_idx].of_Rollback()				
				
				// Create an array of the these transactions.
				li_cnt ++
				ltr_secondary[li_cnt] = atr_control[li_idx]
				li_secondaryrc[li_cnt] = li_rc
			Next
	
			// Provide immediate feedback of the problem.
			li_rc = of_EndTranError(ltr_performed, ltr_secondary, li_secondaryrc, ai_saverc)
			
			// If requested use the assist funtionality.
			If ib_assist Then
				of_assist(is_instancename+'.of_EndTran() failed of_Commit()(s).')
			End If						
			Return -1
		End If
	Else
		If atr_control[li_i].of_Rollback() < 0 Then
			// -- An rollback error has been encountered. --			
			
			// Loop around Other transactions.
			li_cnt = 0
			For li_idx = li_i to li_max
				// Rollback.
				li_rc = atr_control[li_idx].of_Rollback()				
				
				// Create an array of the these transactions.
				li_cnt ++
				ltr_secondary[li_cnt] = atr_control[li_idx]
				li_secondaryrc[li_cnt] = li_rc
			Next			
			
			// Provide immediate feedback of the problem.
			li_rc = of_EndTranError(ltr_performed, ltr_secondary, li_secondaryrc, ai_saverc)			
			
			// If requested use the assist funtionality.
			If ib_assist Then
				of_assist(is_instancename+'.of_EndTran() failed of_RollBack()(s).')
			End If			
			Return -1
		End If		
	End If
	
	// In case there is a problem, Keep track of the transactions successfully ended. 
	ltr_performed[li_i] = atr_control[li_i]
Next

// If requested use the assist funtionality.
If ib_assist Then
	If ai_saverc > 0 Then
		of_assist(is_instancename+'.of_EndTran() successfully executed of_Commit()(s).')
	Else
		of_assist(is_instancename+'.of_EndTran() successfully executed of_Rollback()(s).')
	End If
End If

Return 1
end function

     
Name Owner
pfc_n_cst_luw.of_save pfc_n_cst_luw

     
Name Owner
systemfunctions.isnull systemfunctions
systemfunctions.string systemfunctions
systemfunctions.upperbound systemfunctions
pfc_n_cst_luw.of_getclassnames pfc_n_cst_luw
pfc_n_cst_luw.of_assist pfc_n_cst_luw
pfc_n_cst_luw.of_endtranerror pfc_n_cst_luw
pfc_n_tr.of_RollBack pfc_n_tr
pfc_n_tr.of_Commit pfc_n_tr

     
Full name
No Data

     
Name Scope
No Data