Post
by Alberto Aviles » 03 Dec 2007, 22:49
Posted by: Alberto Aviles
mmm...
we don't use session, we connect the handler when the form is created and
disconnect when the form is close !!
some like this...
on sam_create
call conectaDB( hSqHandler1 ) // all the connectios was made with this
function !!
on sam_Close
Call sqldisconnect( hSqHandler1 )
Function: MakeTransaction
If NOT UpdateTable1 ( hSqHandler1 )
return false
If Not DeleteTable1 ( hSqHandler1 )
return false
.
.
.
return True
Function: TrigerApp
If not MakeTansaction()
call sqlprepareandexecute( hSqHandler1 , 'Roll back')
else
call sqlcommit( hSqHandler1 )
Function: ConectaDB
Description: Hace las conecciones de los hanler's con las debidas
parametrizaciones
Returns
Parameters
Receive Sql Handle: hSql
Number: nModoAislamiento
Static Variables
Local variables
String: sString
Actions
Call SalWaitCursor( TRUE )
Set bOk = FALSE
If SqlConnect(hSql)
Call SqlSetResultSet( hSql, TRUE )
!
! 1
!
If nModoAislamiento = MODO_RL
Call SqlSetIsolationLevel( hSql, 'RL' )
!
! 2
!
If nModoAislamiento = MODO_RC
Call SqlSetIsolationLevel( hSql, 'RC' )
!
! 3
!
If nModoAislamiento = MODO_RO
Call SqlSetIsolationLevel( hSql, 'RO' )
!
!
!
Call SqlSetParameter( hSql, DBP_PRESERVE , TRUE, '' )
Call SqlSetParameter( hSql, DBP_AUTOCOMMIT , FALSE, sString )
Call SqlSetParameter( hSql, DBP_ROLLBACKONTIMEOUT , FALSE, '' )
Call SqlSetLockTimeout( hSql, 15 )
Set bOk = TRUE
Else
Call SalMessageBox( 'No es posible conectar con la base de Datos',
'HANDLER', MB_IconStop )
Set bOk = FALSE
Call SalWaitCursor( FALSE)
Return bOk