Posted by: Thomas Heim
Hi all
I'd like to unload/Load the DB via NT-Service. I'm using SQLWNTM.DLL and the
function sqlsab. This function does not only kill the process it shuts down
the server (
SQLBase 8.5 ) too. Can anybody help to get the correct function?
PLEASE, Help!!!
!!CB!! 145
Function: sqlsab
Description: Abort Database Process
Export Ordinal: 0
Returns
Number: INT
Parameters
Number: WORD
Number: WORD
!!CB!! 134
Function: UdfKillServerProcesses
Description:
Returns
Parameters
Static Variables
Local variables
Number: hServer
String: sProcesses
Number: nLength
Number: nOffset
!
Number: nRecordLength
String: sIsolation
String: sUser
String: sDb
Number: nPID
String: sInfo
Number: nAddOffset
!
String: sDummy
Number: nCountCursors
Actions
! ==> Connect to Server
If SqlServerConnect( hServer, sServerName, "" )
!
!
! ==> If running against SQLBase >= 8.0 set this to 8, otherwise to 0
! ==> You can query the version as follows: SqlGetParameterAll(hSql,
SQLPVER, nTmp, sVersion, FALSE)
Set nAddOffset = 8
!
!
! - Get Processes
Call SqlGetServerProcesses( hServer, sProcesses, nLength )
! Initial Offset
Set nOffset = 12
While nOffset Process ID
Set nOffset = nOffset + 17
Set nPID = CStructGetByte( sProcesses, nOffset )
! ==> Isolation Level
Set nOffset = nOffset + 1
Set nRecordLength = 3
Call SalStrSetBufferLength( sIsolation, nRecordLength )
Call CStructGetString( sProcesses, nOffset, nRecordLength, sIsolation )
! ==> User Name
Set nOffset = nOffset + 3
Set nRecordLength = 19
Call SalStrSetBufferLength( sUser, nRecordLength )
Call CStructGetString( sProcesses, nOffset, nRecordLength, sUser )
! ==> Database Name
Set nOffset = nOffset + 19
Set nRecordLength = 10 + nAddOffset
Call SalStrSetBufferLength( sDb, nRecordLength )
Call CStructGetString( sProcesses, nOffset, nRecordLength, sDb )
! ==> Offset to Beginning of next information
Set nOffset = nOffset + 12 + nAddOffset
!
If sDb = SqlDatabase
If NOT sInfo
Set sInfo = 'PID Database User Isolation
'
Set sInfo = sInfo || SalNumberToStrX( nPID, 0 ) || ' ' || sDb || ' ' ||
sUser || ' ' || sIsolation || '
'
!
Call Call sqlsab( hServer, nPID )
! ==> Disconnect From Server
Call SqlServerDisconnect( hServer )
!