Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
didierodayo
Partner - Creator III
Partner - Creator III

Rename Table Name before storing

Hello,

I have the script below which is reading the table names from Tables and then assigning while loading from sql. The script is working fine.

Now I need to rename table5  to Table6

table4 to Table7 

before Storing them.

The original script without the renaming which works.

Tables:
Load * Inline [name
table1
table2
table3
table4
table5
];


For i = 0 to NoOfRows('Tables')-1
Let TN = Peek('name',$(i),'Tables');
TRACE Processing File: $(TN).qvd;
$(TN):
LOAD*;
SQL SELECT *
FROM $(TN);

STORE $(TN) into $(vQVDExtractPath)Tables_$(TN).qvd (qvd);
Drop Table $(TN);
Next i;

The script with the renaming which is not working.

Tables:
Load * Inline [name
table1
table2
table3
table4
table5
];


For i = 0 to NoOfRows('Tables')-1
Let TN = Peek('name',$(i),'Tables');
TRACE Processing File: $(TN).qvd;
$(TN):
LOAD*;
SQL SELECT *
FROM $(TN);

Let StoreName = If(Match($(TN),'table4'),'Table7',

                              If(Match($(TN),'table5'),'Table6',$(TN)));

STORE $(TN) into $(vQVDExtractPath)Tables_$(StoreName ).qvd (qvd);
Drop Table $(TN);
Next i;

How could this be achieved?

1 Solution

Accepted Solutions
didierodayo
Partner - Creator III
Partner - Creator III
Author

OK   I got it to work. was just missing quotes on the variable names.

Tables:
Load * Inline [name
table1
table2
table3
table4
table5
];


For i = 0 to NoOfRows('Tables')-1
Let TN = Peek('name',$(i),'Tables');

Let StoreName = If(Match('$(TN)','table4'),'Table7',

                              If(Match('$(TN)','table5'),'Table6','$(TN)'));


TRACE Processing File: $(TN).qvd;
$(TN):
LOAD*;
SQL SELECT *
FROM $(TN);

STORE $(TN) into $(vQVDExtractPath)Tables_$(StoreName ).qvd (qvd);
Drop Table $(TN);
Next i;

View solution in original post

1 Reply
didierodayo
Partner - Creator III
Partner - Creator III
Author

OK   I got it to work. was just missing quotes on the variable names.

Tables:
Load * Inline [name
table1
table2
table3
table4
table5
];


For i = 0 to NoOfRows('Tables')-1
Let TN = Peek('name',$(i),'Tables');

Let StoreName = If(Match('$(TN)','table4'),'Table7',

                              If(Match('$(TN)','table5'),'Table6','$(TN)'));


TRACE Processing File: $(TN).qvd;
$(TN):
LOAD*;
SQL SELECT *
FROM $(TN);

STORE $(TN) into $(vQVDExtractPath)Tables_$(StoreName ).qvd (qvd);
Drop Table $(TN);
Next i;