Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikWorld 2020: Join us May 11 - 14, 2020 in Phoenix, AZ. Register early and save $400. Learn More
shyamcharan
Contributor III

Get SQL script from a table field value with For and Next Loop

Hi Experts,

I am trying to read sql scripts from an excel file which are placed in a field called 'LoadStatement'.

Using For and Next loop I am trying to get the Select statement from each one of the field  value (LoadStatement) against the tablenames of the ExtractList.xls to load the data from database. If not Select statement available it should default to 'SQL Select * from TableName' as defined in variables.

However, it only picks first Select statement and all others are defaulted to 'SQL Select * from TableName' statement defined in the For-Next loop.

I have attached all the files I am using to get this worked.

Could you please advise what I am missing.

Appreciate your help here. Thanks in advance.

Labels (1)
1 Solution

Accepted Solutions

Re: Get SQL script from a table field value with For and Next Loop

Hi, with FieldValue you read the values from field, in example LoadStatementCheck only has values 1 and 0 (only 2 values, not 4 like excel rows). To load the table by rows you can try with Peek() and NoOfRows():

FOR i=0 to NoOfRows('ExtractList')-1 // Peek starts at 0

LET vQVDName = Peek('QvdName',$(i),'ExtractList') ; 

 

View solution in original post

2 Replies

Re: Get SQL script from a table field value with For and Next Loop

Hi, with FieldValue you read the values from field, in example LoadStatementCheck only has values 1 and 0 (only 2 values, not 4 like excel rows). To load the table by rows you can try with Peek() and NoOfRows():

FOR i=0 to NoOfRows('ExtractList')-1 // Peek starts at 0

LET vQVDName = Peek('QvdName',$(i),'ExtractList') ; 

 

View solution in original post

shyamcharan
Contributor III

Re: Get SQL script from a table field value with For and Next Loop

Thanks heaps Rubenmarin. 

That worked.