-1

I have a variable called LV_MAIN which is having value as LV_TEMP and now I want to assign value to LV_TEMP and write select for LV_TEMP. How can I achieve this?

To explain in detail:

LV_MAIN := LV_TEMP 

and now I want to assign:

LV_TEMP := '7'

and want to execute:

SELECT :LV_TEMP FROM DUMMY;

How can I do that?

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Saurav
  • 48
  • 6
  • 1
    `set`. Sql Server doesn't use the dummy table. – shawnt00 Jul 29 '20 at 04:49
  • i know sql server do not use dummy table... i am writing it in HANA ... ignore about database ..... kindly let me know if there is any solution for my query ?? – Saurav Jul 29 '20 at 05:12

1 Answers1

1

To execute SQL Script, a "logic container" is required.

This "logic container" can be a trigger, a stored procedure, a table function, or an anonymous block.

For simple once-off queries or prototyping, the anonymous block is the option most readily usable:

DO BEGIN -- this indicates the start of the anon. block
DECLARE lv_temp NVARCHAR(2) := '7';

SELECT 
     :lv_temp 
FROM 
    DUMMY;

END; -- this indicates the end of the anon. block
Lars Br.
  • 9,949
  • 2
  • 15
  • 29