Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
BartSleegers
Contributor
Contributor

Loading a list of tables in a loop

Hi there,

I am trying to load a list of tables.  The first table works correctly, but the peek function cannot find the second table. Does anybody know what is wrong in my script?

===========================
[Tables]:

load * inline [

TableName

PJ_HEADERS

LK_KLANT


];

FOR i=0 to NoOfRows('Tables')-1

let t=Peek('TableName', $(i));

trace table to read is $(t);


set st= SELECT * FROM $(t);

trace sql statement is $(st);


$(t):

LOAD *;

SQL

$(st);


NEXT;

===============================

Labels (2)
1 Solution

Accepted Solutions
salezian
Creator
Creator

Hi,

Change:

 

let t=Peek('TableName', $(i));

 

to

 

let t=Peek('TableName',i,'Tables');

 

 The reason why the statement is failing is:

If no table_name is stated, the current table is assumed. If used outside the LOAD statement or referring to another table, the table_name must be included.

So after first iteration Peek function is looking for 'TableName' in PJ_HEADERS table.

KR

Marcin.

View solution in original post

2 Replies
salezian
Creator
Creator

Hi,

Change:

 

let t=Peek('TableName', $(i));

 

to

 

let t=Peek('TableName',i,'Tables');

 

 The reason why the statement is failing is:

If no table_name is stated, the current table is assumed. If used outside the LOAD statement or referring to another table, the table_name must be included.

So after first iteration Peek function is looking for 'TableName' in PJ_HEADERS table.

KR

Marcin.

BartSleegers
Contributor
Contributor
Author

Many thxs for your quick reply, Marcin. This works