Menu

document Function - ParametersMem

ema manu

SetParameterMem
GetParameters
ClearMem

This 3 functions allow to keep in memory for each session id some parameters.
What s mean?!?!
Imagine you have managment studio with 2 query editor.
Each of this have 2 differents session id, for example id1, id2.
Now try this example:

example

on id1

select [dbo].[SetParameterMem]('@p1','0')
select [dbo].[SetParameterMem]('@p2','3')

select * from [dbo].[GetParametersMem]('@p1')
select * from [dbo].[GetParametersMem]('')

on id2

select [dbo].[SetParameterMem]('@p1','0')
select [dbo].[SetParameterMem]('@p5','3')

select * from [dbo].[GetParametersMem]('@p5')
select * from [dbo].[GetParametersMem]('')

Ok, now i hope you have understood what i meant...

I developed this because in a web server you have only one user that is running, but if you set the connection string with "pooling=false" you can have a new session id everytime.

And then???
Then, try to think to open a new connection and the first thing you ll do is

select [dbo].[SetParameterMem]('@suer','userid')

Now until you close this connection you ll have in memory the userid that execute the sql command and you could log it, or use it to extract only the data it need...

And what happened when i close the session?
Nothing, to remove closed session from memory you have to execute

select [dbo].[ClearMem]()

that remove all and only close session.

To have all parameters setted in memory from different sessions you have to execute

select * from [dbo].[GetParametersMem]('*')


Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.