Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all
LEt's say i have a script like below in the meaning to store csv files
exporttemp:
noconcatenate
load
MonthYear,
SUP,
"LOG",
NOM,
FILE,
INDICATEURS,
sum(PROD.VOL.PROD) as Nombre,
sum(time(TEMPS,'hh:mm:ss')) as Durée,
"TYPE"
resident tempqvd
where SUP='AURELIE'
group by MonthYear,SUP,"LOG",NOM,FILE,INDICATEURS,TYPE
order by MonthYear desc,SUP,"LOG",NOM,INDICATEURS,FILE,TYPE;
Store exporttemp into [lib://Final_Prod/AURELIE.csv](txt);
drop table tempqvd;
drop table exporttemp;
As you can see i Store the date where field SUP is = to AURELIE .
In this field i have different name and i would like to store a csv field by name. So that if in my field SUP I Have AURELIE it will store data into AURELIE.CSV , if my field SUP = to ERIC it will save a csv field as ERIC.csv and so on ...
How i can use a variable and may be the fieldindex statemement to detect the NAME and then store for each a CSV.File with there regarding data ?
Help will be appreciate
Thanks in advance
Hi,
You can do it by using for loop and variable....there may be other way too.
Here the solution which might work for you
Load the base table with only 1 field SUP
Sup_temp_tb:
Load distinct
SUP
Resident tempqvd;
Let vNumRows = NoOfrows ('Sup_temp_tb');
//We will write the for loop to iterate through the sup values
For i=0 to $(vNumRows)-1
//Will store the single SUP value in variable and iterate it and store the qvd
Let vSUPVal = peek('SUP',$(i),'Sup_temp_tbl');
exporttemp:
noconcatenate
load
MonthYear,
SUP,
"LOG",
NOM,
FILE,
INDICATEURS,
sum(PROD.VOL.PROD) as Nombre,
sum(time(TEMPS,'hh:mm:ss')) as Durée,
"TYPE"
resident tempqvd
where SUP='$(vSUPVal)'
group by MonthYear,SUP,"LOG",NOM,FILE,INDICATEURS,TYPE
order by MonthYear desc,SUP,"LOG",NOM,INDICATEURS,FILE,TYPE;
Store exporttemp into [lib://Final_Prod/$(vSUPVal).csv](txt);
Drop table exporttemp;
Next
//Once the loop is over drop all the tables that are loaded.
Drop table Sup_temp_tb;
Regards,
Prashant
Hi,
You can do it by using for loop and variable....there may be other way too.
Here the solution which might work for you
Load the base table with only 1 field SUP
Sup_temp_tb:
Load distinct
SUP
Resident tempqvd;
Let vNumRows = NoOfrows ('Sup_temp_tb');
//We will write the for loop to iterate through the sup values
For i=0 to $(vNumRows)-1
//Will store the single SUP value in variable and iterate it and store the qvd
Let vSUPVal = peek('SUP',$(i),'Sup_temp_tbl');
exporttemp:
noconcatenate
load
MonthYear,
SUP,
"LOG",
NOM,
FILE,
INDICATEURS,
sum(PROD.VOL.PROD) as Nombre,
sum(time(TEMPS,'hh:mm:ss')) as Durée,
"TYPE"
resident tempqvd
where SUP='$(vSUPVal)'
group by MonthYear,SUP,"LOG",NOM,FILE,INDICATEURS,TYPE
order by MonthYear desc,SUP,"LOG",NOM,INDICATEURS,FILE,TYPE;
Store exporttemp into [lib://Final_Prod/$(vSUPVal).csv](txt);
Drop table exporttemp;
Next
//Once the loop is over drop all the tables that are loaded.
Drop table Sup_temp_tb;
Regards,
Prashant
Hi Prashant
Thank's a lot for your help
Regard's
Bruno
Welcome😊