of_endtranerror


pfcapsrv.pbl   >   pfc_n_cst_luw   >   of_endtranerror   

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

Name Datatype
No Data

Name Datatype
li_idx Integer
li_maxperformed Integer
li_maxsecondary Integer
ls_msg string
ls_msgheader string
ls_msgmainerror string
ls_msgperformed string
ls_msgperformedheader string
ls_msgsecondary string
ls_msgsecondaryheader string
ls_name string
ltr_obj n_tr[]

protected function integer of_endtranerror (n_tr atr_performed[], n_tr atr_secondary[], integer ai_secondaryrc[], integer ai_saverc);//////////////////////////////////////////////////////////////////////////////
//
//	Function:  of_EndTranError
//
//	Access:  protected
//
//	Arguments:
//	atr_performed[]   Array of controls which unfortunately successfully ended.
//	atr_secondary[]
//	ai_secondaryrc[]
// ai_saverc		The current Save Return code used to determine how to end
//						the transaction.
//
//	Returns:  integer
//	 1 = Succesful
//	-1 = An error was found
//
//	Description:
//		End Transaction error was encountered.  Provide feedback of this error.
//
//////////////////////////////////////////////////////////////////////////////
//	
//	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_maxperformed
Integer	li_maxsecondary
Integer 	li_idx
n_tr		ltr_obj[]
string	ls_name
string	ls_msg
string	ls_msgheader
string	ls_msgmainerror
string	ls_msgperformedheader
string	ls_msgperformed
string	ls_msgsecondaryheader
string	ls_msgsecondary

// Validate the arguments.
If IsNull(atr_performed) Then Return -1
If IsNull(atr_secondary) Then Return -1
If IsNull(ai_secondaryrc) Then Return -1
If IsNull(ai_saverc) Then Return -1

// Get the upperbound.
li_maxperformed = UpperBound(atr_performed)
li_maxsecondary = UpperBound(atr_secondary)
If li_maxsecondary <= 0 Then Return -1

If ai_saverc > 0 Then
	ls_msgheader = 'A Database Transaction error has been encountered.~r~n~r~n'+&
		'The LUW.of_EndTran() function was to execute Commits to all the transactions.~r~n'+ &
		'The following details the problem.~r~n~r~n'
	ls_msgmainerror = 'The transaction statement that started the error - '+ &
		atr_secondary[1].ClassName()+'('+atr_secondary[1].of_GetName()+').of_Commit()' + &
		'~r~n~r~n'
	If li_maxperformed > 0 Then
		ls_msgperformedheader = 'Prior to the error the following transactions were Committed:~r~n'
	End If
	ls_msgsecondaryheader = 'After the error, the following were executed:~r~n'
Else
	ls_msgheader = 'A Database Transaction error has been encountered.~r~n~r~n'+&
		'The LUW.of_EndTran() function was to execute Rollbacks to all the transactions.~r~n'+ &
		'The following details the problem.~r~n~r~n'
	ls_msgmainerror = 'The transaction statement that started the error - '+ &
		atr_secondary[1].ClassName()+'('+atr_secondary[1].of_GetName()+').of_Rollback()' + &
		'~r~n~r~n'		
	If li_maxperformed > 0 Then
		ls_msgperformedheader = 'Prior to the error the following transactions were Rollback:~r~n'
	End If
	ls_msgsecondaryheader = 'After the error, the following were executed:~r~n'
End If

// Loop around all performed transactions.
For li_idx = 1 to li_maxperformed
	If Len(ls_msgperformed) > 0 Then ls_msgperformed += ', ~r~n'
	ls_msgperformed += atr_performed[li_idx].ClassName()+ &
		'('+atr_performed[li_idx].of_GetName()+')'
Next
If Len(ls_msgperformed) > 0 Then ls_msgperformed += '~r~n~r~n'

// Loop around the secondar transactions.
For li_idx = 1 to li_maxsecondary
	If Len(ls_msgsecondary) > 0 Then ls_msgsecondary += ', ~r~n'
	ls_msgsecondary += atr_secondary[li_idx].ClassName()+ &
		'('+atr_secondary[li_idx].of_GetName()+').of_RollBack()' + &
		' return code= '+string(ai_secondaryrc[li_idx])
Next

// Construct the total message.
ls_msg = ls_msgheader + &
			ls_msgmainerror + &
			ls_msgperformedheader + &
			ls_msgperformed + &
			ls_msgsecondaryheader + &
			ls_msgsecondary

// Display the error if there are more than one transactions involved.
If li_maxperformed + li_maxsecondary >= 2 Then
	of_Messagebox('pfc_luw_endtranerror','Save',ls_msg,StopSign!,Ok!,1)
End If

// If requested use the assist funtionality.
If ib_assist Then
	of_assist(is_instancename+'.of_EndTranError()  '+ ls_msg)
End If

Return 1
end function

     
Name Owner
pfc_n_cst_luw.of_endtran pfc_n_cst_luw

     
Name Owner
powerobject.classname powerobject
systemfunctions.isnull systemfunctions
systemfunctions.len systemfunctions
systemfunctions.string systemfunctions
systemfunctions.upperbound systemfunctions
pfc_n_cst_luw.of_assist pfc_n_cst_luw
pfc_n_base.of_messagebox pfc_n_base
pfc_n_tr.of_GetName pfc_n_tr

     
Full name
No Data

     
Name Scope
No Data