#sql("sjjhBylp")
MERGE INTO jc_lp T1
USING (
select
#for(x : cond)
#if(x.value==null||x.value=="")
'' as #(x.key)
#else
#if("shsj"==x.key||"ccsj"==x.key||"xgsj"==x.key||"zhgxsj"==x.key)
to_timestamp(#("'"+x.value+"'"),'yyyy-mm-dd hh24:mi:ss.ff') as #(x.key)
#else
#("'"+x.value+"'") as #(x.key)
#end
#end
#(for.last?"":",")
#end
from dual) T2
ON ( T1.id=T2.id)
WHEN MATCHED THEN
UPDATE SET
#for(x : cond)
#if("id"!=x.key)
T1.#(x.key) = T2.#(x.key)
#(for.last?"":",")
#end
#end
WHEN NOT MATCHED THEN
INSERT (
#for(x : cond)
#(x.key)
#(for.last?"":",")
#end
) VALUES(
#for(x : cond)
T2.#(x.key)
#(for.last?"":",")
#end
);
#end
上面的代码#if("shsj"==x.key||"ccsj"==x.key||"xgsj"==x.key||"zhgxsj"==x.key) 这行能否改成判断字段值的类型?如上面的写法怎么能优化下
z = x.key,
map = { shsj : z, ccsj : z, xgsj : z, zhgxsj : z}
}
#if (map.containsValue(z))