Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I´d like to create simething like this:
set vtable = 'TAB01'
SET vtable = TAB01;
Table:
SQL Select * From $(vtable);
u have to use ur variable in sql with $ symbol.
Hi,
So, what I need is to create a variable because my sql will be dynamic! No just the table I´ll change... I used this example just so simplify!
The real situation is that I need to put many 'unions' in my sql!
Build up the sql statement in a variable then execute it:
SET vTable = MyTable;
LET vWhere = 'MyField > 0'
SET vSQL = SELECT * FROM $(vTable) $(vWhere);
Table:
SQL $(vSQL);
However "@SQL" is a variable in SQL, not in Qlikview!
i mean in qlikview sql script u have to use $ symbol..if u want to use the variable.
Much easier if you move all your dynamic logic into a procedure
set vtable = 'TAB01'
I got this way:
set xpto = '';
let counter = 1;
let xempa = '010060';
do while counter < 3
let xemp = mid($(xempa),1,3);
if $(counter) > 1 then
set xpto = $(xpto) union all ;
set xpto = $(xpto) Select top 10 $(counter) as emp, E1_NUM from SE1$(xemp);
Else
set xpto = Select top 10 $(counter) as emp, E1_NUM from SE1$(xemp);
Endif
let counter = counter + 1;
let xempa = mid($(xempa),4,len($(xempa))-3);
loop
teste:
SQL
$(xpto);
Thanks a lot everybody!