Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
shyamcharan
Creator III
Creator 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
rubenmarin

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
rubenmarin

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') ; 

 

shyamcharan
Creator III
Creator III
Author

Thanks heaps Rubenmarin. 

That worked.