Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Rotha_HUOCH
Contributor
Contributor

Run a stored procedure that contains a cursor

Hello,

I am calling the community because I need your help to execute a stored procedure.

I am able to run a simple stored procedure that contains an insert, using the following components:

0693p00000ADdFSAA1.png

It works very well.

Now I want to run the stored procedure below:

DECLARE @v_spid INT

DECLARE c_Users CURSOR

  FAST_FORWARD FOR

  SELECT SPID

  FROM master..sysprocesses (NOLOCK)

  WHERE spid>50

  AND loginame <> 'DIR%'

  AND program_name LIKE N'%Microsoft Dynamics NAV Classic client                                              %'

  AND status='sleeping'

  AND DATEDIFF(mi,last_batch,GETDATE())>=25

  AND spid <> @@spid

OPEN c_Users

FETCH NEXT FROM c_Users INTO @v_spid

WHILE (@@FETCH_STATUS=0)

BEGIN

 PRINT 'Killing '+ CONVERT(VARCHAR,@v_spid)+'...'

 EXEC('KILL '+ @v_spid)

 FETCH NEXT FROM c_Users INTO @v_spid

END

CLOSE c_Users

DEALLOCATE c_Users

The purpose of this procedure is to disconnect users who are inactive for more than 30 minutes (in the erp).

It works great when I run it manually via ssms.

On the other hand, when I run it via Talend, I have no error message but it is obviously not executed since inactive users remain connected

0693p00000ADdLQAA1.png

0693p00000ADdMnAAL.png

0693p00000ADdMTAA1.png

Labels (3)
5 Replies
Rotha_HUOCH
Contributor
Contributor
Author

wow, still no answer after months of waiting 😞

Could a nice super user help me or give me a link to a solution?

gjeremy1617088143

Hi, have you try a tDBRow with :

"EXEC kill_sessions;" ?

Send me Love and kudos

 

 

Rotha_HUOCH
Contributor
Contributor
Author

Let me check

Rotha_HUOCH
Contributor
Contributor
Author

I don't think it's working because right after I execute le talend job, the users are still connected :

0695b00000G2rbxAAB.png0695b00000G2rf5AAB.png

pawe84
Creator
Creator

Have the same issue. No one has a solution for it?