Quantcast
Channel: Pentaho Community Forums
Viewing all articles
Browse latest Browse all 16689

Select from db based on file conditions

$
0
0
I have a mysql db with a table with this fields: ID, country.

ID;Country
1;Usa
2;Germany
3;Usa
4;Italy
5;Usa
and so on

Then I have a csv file with some quotas:

Country;Quota
Usa;2
Italy;1
and so on


Objective is to extract from the db table n rows per country (where n is the quota field). So I need a file or to write in the same mysql db some field as output.

Output file

ID
1
3
4

where 1 and 3 are the IDs of Usa country and 4 is the ID of Italy.

I don't have problem with input and output step, but with the flow in the middle.

My ideas is:
- read the first input csv file row (Usa;2)
- use it in the query: SELECT ID FROM mysqltable where country = 'Usa' LIMIT 2
- write the results on the output table

repeat this loop until rows in the csv file ends.

I'm not able to use a loop to do this and to use the parameters that I dynamically give to the query.

Any idea? Also what blocks I need to use..

Viewing all articles
Browse latest Browse all 16689


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>