Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
ali_hijazi
Partner - Master II
Partner - Master II

looping a script

Hello I got to fetch data from several servers that contain the same database schema (i.e. same table names,etc...)

I want to change the connection string on each loop and save each table in a distinct qvd

what I want to parameterize is the following:

OLEDB CONNECT TO [Provider=SQLOLEDB.1;Persist Security Info=False;Data Source=entUAE;Initial Catalog=PS_DEV;User ID=RO;Password=RO;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=HANI-SAGHEER;Use Encryption for Data=False;Tag with column collation when possible=False];
F4311:LOAD *;SQL
Select dbo.fn_ConvertJulianToDate(PDTRDJ) as PDDATE, * from testdta.F4311 where PDDCTO in ('OM','OC','OL');

store F4311 into $(vQvdPath)F4311_entUAE.qvd(qvd);DROP Table F4311;

the info in yellow highlight will change according to the loop.

I can walk on water when it freezes
1 Solution

Accepted Solutions
ali_hijazi
Partner - Master II
Partner - Master II
Author

as for the connection string you can store the connection strings in txt files and inside the for loop you can read the desired txt file using the following command:

$(Include=$(i).txt);

I can walk on water when it freezes

View solution in original post

4 Replies
whiteline
Master II
Master II

Hi.

You can use 'for' statement to loop it.

Also you could create an inline table with serverNames to pick one for each iteration with fieldvalue() or peek() functions.

ali_hijazi
Partner - Master II
Partner - Master II
Author

using peek or fieldvalue works for the load script as follows:

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

LET sheetName = 'vDolphin.dbo.' & peek('name',i,'tables');

LOAD *;

sql select * from $(sheetName);

NEXT

but how can I make the connection string in the ODBC Connect or OLEDB Connect dynamic?

I can walk on water when it freezes
ali_hijazi
Partner - Master II
Partner - Master II
Author

as for the connection string you can store the connection strings in txt files and inside the for loop you can read the desired txt file using the following command:

$(Include=$(i).txt);

I can walk on water when it freezes
whiteline
Master II
Master II

You can also use the same approach as with $(vQvdPath).