我目前正在尝试什么都不做,比从一些列中获取所有行值并将它们加在一起。那部分工作正常,甚至一次成功:D。但是当删除数据并尝试再次运行作业时,我遇到了Casting错误。为了您的信息,我目前对此解决方案的尝试是:
从Excel读取数据(将所有内容转换为整数)=>选择所有重要字段(选择值)=>添加常量(追加结果字段)=> UDJC(从数据集中总结每一行)=>更新数据库
我不明白为什么,因为我使用的是所有整数。也许这里的某个人可以帮助我,我想这是我想念的蠢事。
recasting them inside select values
我的用户定义的Java类代码如下所示
public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException {
if (first) {
first = false;
}
Object[] r = getRow();
if (r == null) {
setOutputDone();
return false;
}
// It is always safest to call createOutputRow() to ensure that your output row's Object[] is large
// enough to handle any new fields you are creating in this step.
r = createOutputRow(r, data.outputRowMeta.size());
/* TODO: Your code here. (See Sample)
// Get the value from an input field
String foobar = get(Fields.In, "a_fieldname").getString(r);
foobar += "bar";
// Set a value in a new output field
get(Fields.Out, "output_fieldname").setValue(r, foobar);
*/
int result_value = 0;
int value10 = get(Fields.In, "int_10").getInteger(r).intValue();
int value20 = get(Fields.In, "int_20").getInteger(r).intValue();
int value30 = get(Fields.In, "int_30").getInteger(r).intValue();
int value40 = get(Fields.In, "int_40").getInteger(r).intValue();
int value50 = get(Fields.In, "int_50").getInteger(r).intValue();
int value60 = get(Fields.In, "int_60").getInteger(r).intValue();
int value70 = get(Fields.In, "int_70").getInteger(r).intValue();
int value80 = get(Fields.In, "int_80").getInteger(r).intValue();
int value90 = get(Fields.In, "int_90").getInteger(r).intValue();
int value100 = get(Fields.In, "int_100").getInteger(r).intValue();
int value110 = get(Fields.In, "int_110").getInteger(r).intValue();
int value120 = get(Fields.In, "int_120").getInteger(r).intValue();
int value130 = get(Fields.In, "int_130").getInteger(r).intValue();
int value140 = get(Fields.In, "int_140").getInteger(r).intValue();
int value150 = get(Fields.In, "int_150").getInteger(r).intValue();
int value160 = get(Fields.In, "int_160").getInteger(r).intValue();
int value170 = get(Fields.In, "int_170").getInteger(r).intValue();
int value180 = get(Fields.In, "int_180").getInteger(r).intValue();
int value190 = get(Fields.In, "int_190").getInteger(r).intValue();
int value200 = get(Fields.In, "int_200").getInteger(r).intValue();
int value210 = get(Fields.In, "int_210").getInteger(r).intValue();
int value220 = get(Fields.In, "int_220").getInteger(r).intValue();
result_value = (value10 + value20 + value30 + value40 + value50 + value60 +
value70 + value80 + value90 + value100 + value110 + value120 +
value130 + value140 + value150 + value160 + value170 + value180 +
value190 + value200 + value210 + value220);
get(Fields.Out, "neutral_or_personal").setValue(r, result_value);
// Send the row on to the next step.
putRow(data.outputRowMeta, r);
return true;
}