DBLookup

Hello. I’m new to clover ETL and I have the following problem, basically what I want to do is to lookup for a register in a db, compare it to another one in a txt file, and if they arent equals, filter it and sent it to a trash. But I have a fatal error in the writer and I dont know why, besides, there is not much clover info on net from what I can see.

ERROR [WatchDog] - Phase initialization failed with reason: WRITER …FATAL ERROR !
WRITER …FATAL ERROR !
at org.jetel.graph.Phase.init(Phase.java:163)
at org.jetel.graph.runtime.WatchDog.executePhase(WatchDog.java:565)
at org.jetel.graph.runtime.WatchDog.call(WatchDog.java:155)
at org.jetel.graph.runtime.WatchDog.call(WatchDog.java:70)
at java.util.concurrent.FutureTask$Sync.innerRun(libgcj.so.81)
at java.util.concurrent.FutureTask.run(libgcj.so.81)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(libgcj.so.81)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(libgcj.so.81)
at java.lang.Thread.run(libgcj.so.81)
Caused by: java.lang.RuntimeException: Failed initialization of filler buffers :java.lang.IllegalStateException
at org.jetel.data.formatter.FixLenDataFormatter.initRecordFiller(FixLenDataFormatter.java:134)
at org.jetel.data.formatter.FixLenDataFormatter.init(FixLenDataFormatter.java:171)
at org.jetel.util.MultiFileWriter.prepareTargets(MultiFileWriter.java:165)
at org.jetel.util.MultiFileWriter.init(MultiFileWriter.java:126)
at org.jetel.component.FixLenDataWriter.init(FixLenDataWriter.java:218)
at org.jetel.graph.Phase.init(Phase.java:158)

The grf is:

[code]<?xml version="1.0" encoding="UTF-8"?>













<![CDATA[select * from clientes where Numero_abonado_A=?]]>





<![CDATA[
import org.jetel.component.DataRecordTransform;
import org.jetel.data.DataRecord;
import org.jetel.data.RecordKey;
import org.jetel.data.lookup.LookupTable;
import org.jetel.exception.JetelException;
import org.jetel.graph.TransformationGraph;

public class reformatTest extends DataRecordTransform{

LookupTable mylookup;

public boolean init(){

try {
mylookup = graph.getLookupTable(“LookupTable0”);
mylookup.init();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

// create key
String lookupKeyStr={“Numero_abonado_A”};
RecordKey key=new RecordKey(lookupKeyStr,sourceMetadata[0]);
key.init();
mylookup.setLookupKey(key);
return true;
}

public boolean transform(DataRecord source, DataRecord target)
{
DataRecord employee;

employee=mylookup.get(source[0]);

if (employee==null) {// skip this one
errorMessage = “Order: " + source[0].getField(0).getValue() + " - no corresponding record in lookup table”;
System.out.println("Dentro del source: "+source[0]);
return false;
}

//target[0].getField(0).setValue(source[0].getField(0).getValue());
//target[0].getField(1).setValue(source[0].getField(1).getValue());
//target[0].getField(2).setValue(source[0].getField(2).getValue().toString());
//target[0].getField(3).setValue(employee.getField(0).getValue().toString());
//target[0].getField(4).setValue(employee.getField(1).getValue());

return true;
}
}
]]>





And the metada is:

<?xml version="1.0" encoding="UTF-8"?>

This is based on graphDBLookup.grf of the examples.

Thanks so much. I really need this.[code][/code][/quote][code][/code]

Hi,
for joining data from flat file with database attends DBJoin Component.
See following examples:
DBJoin example
DB unload parametrized example
Lookup join example

For writing data to file use rather Universal Data Writer than Fixlen DW. In GUI you can use edge debugger for data preview.