on 2018 Sep 04 2:57 PM
Hello,
I am trying to set the session variable in SAP HANA, as described here:
SET [SESSION] Statement (Session Management)
command: SET 'MY_VAR' = 'abc';
is successful, but when I am trying to retrieve back the value using the command:
SELECT SESSION_CONTEXT('MY_VAR') FROM DUMMY;
It's returning me null value.
Request clarification before answering.
Hi, Florian Pfeffer and Lars Breddemann thanks to both of you for your replies.
I got the Idea from your comments, and after researching little more I came to know, each query I was running in the SQL console was getting executed in a new session.
To confirm the commands are working, I created a procedure, containing both set and select commands for a session variable.
CREATE PROCEDURE "SCHEMA_NAME"."CHANGE_SESSION_VAR" (OUT sessionVar NVARCHAR(5))
AS
BEGIN
SET 'mySessionVar' = 'jmk';
SELECT SESSION_CONTEXT('mySessionVar') into sessionVar FROM DUMMY;
END
And it worked, as invoking this procedure is executing both the internal queries in the same session.
Thanks again for your comments.😊
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 18 | |
| 7 | |
| 6 | |
| 6 | |
| 6 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.