You are not logged in.
Announcement
Unanswered posts
|
Pages: 1
Hi,
One questions regarding the tDBInput or similar component.
I want to syn database from a transaction database (TXDB) into my BI database (BIDB) periodically.
For the very first syn, I will pull all rows of relevant tables from TXDB to BIDB.
However, subsequently for everyday, I will want to say syn just rows belonging to 1 month before today and 1 month after today. How can I achieve this? i.e. is there anyway to pass in filtering parameters into the WHERE clause of the QUERY property of tDBInput?
Thanks
TOS Recruit
Offline

Hello,
Adding parameters to your SQL query is very easy.
Here is an example in Java :
"select id, name from employee where field_date>'"+ minDate + "' and field_date<'" + maxDate + "'"
The question is how to initialize your parameters.
In Java, my advice is to add a new routine :
//template routine Java
package routines;
import java.util.Calendar;
import java.text.SimpleDateFormat;
import java.text.FieldPosition;
import java.util.Date;
public class MyRoutine {
public static String dynamicDateInitExample(int diff) {
StringBuffer result = new StringBuffer();
Calendar myCalendar = Calendar.getInstance();
myCalendar.add(Calendar.MONTH, diff);
Date myMinDate = myCalendar.getTime();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
sdf.format(myMinDate, result, new FieldPosition(0));
return result.toString();
}
}and then in your DBInput Query :
"select id, name from employee where field_date>'" + MyRoutine.dynamicDateInitExample(-1) + "' and field_date<'" + MyRoutine.dynamicDateInitExample(1) + "'"
Regards,
Michaël
Last edited by mhirt (2007-08-15 16:49:12)
Offline
Pages: 1