Kill Session using Codeunit

Angelo
Member Posts: 180
Hello Master,
is it possible to make function for killing session without using Store Procedure(ADO)? That's mean just using C/AL code.Anybody can share,please?
Regards,
Angelo
is it possible to make function for killing session without using Store Procedure(ADO)? That's mean just using C/AL code.Anybody can share,please?
Regards,
Angelo
0
Comments
-
Searching the forum for "session kill" can get some good results, see the How to:
http://www.mibuso.com/howtoinfo.asp?FileID=18
or article below...
viewtopic.php?t=26024&highlight=session+kill
-Lavin-Lavin
"Profanity is the one language all programmers know best."0 -
Ok,Thanks klavin...
I got the clue now...
My next question, How to setfilter "duration" datatype? as we know that duration has value for day,hour,minutes,second.
for e.g 1 day 5 hours 40 minutes 8 seconds. How to filter idle time in session table for more than 2 hours ?
session.setfilter("idle time", ???);0 -
please forget my last question....
I've already got the answer... \:D/
Thanks....0 -
With SQL Server you could also kill idle session with some TSQL:
use [master] go set statistics io off set nocount on go declare @threshold datetime set @threshold = dateadd(hour, -6, getdate()) -- threshold is 6 hours ago print 'Killing processes which executed "Last Batch" before ' + convert(varchar(30), @threshold, 113) print '' declare @spid int, @last_batch datetime declare spid_cur cursor for select [spid], [last_batch] from sysprocesses where [program_name] = 'Microsoft Business Solutions-Navision client' -- change application name here and [last_batch] <= @threshold open spid_cur fetch next from spid_cur into @spid, @last_batch while @@fetch_status = 0 begin print 'Killing process ' + convert(varchar(5), @spid) + ', idle since ' + convert(varchar(30), @last_batch, 113) exec ('kill ' + @spid) fetch next from spid_cur into @spid, @last_batch end close spid_cur deallocate spid_cur go
This script searches for NAV processes which have executed the last batch 6 hours ago (please change the settings if applicable) and kills them. YOu could create a SQL Agent job which execute this script every hours.
If necessary you have to add some exception handling etc..
USE AT OWN RISK!Jörg A. Stryk (MVP - Dynamics NAV)
NAV/SQL Performance Optimization & Troubleshooting
STRYK System Improvement
The Blog - The Book - The Tool0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions