如何添加多个更新sql语句?在这个例子中,ID为2,3,4,5
的人public static final Operation INSERT_LANGUAGE_DATA =
Operations.sequenceOf(Operations.insertInto("LANGUAGE")
.columns("ID","DWH_CODE", "LANGUAGE" ,"NAME")
.values(1, 0, "en", "language.english")
.values(2, 7, "cs", "language.czech")
.values(3, 1, "de", "language.german")
.values(4, 2, "es", "language.spanish")
.values(5, 3, "fr", "language.french")
.build(),
sql("UPDATE CUSTOMER set LANGUAGE_ID = 1 where ID = 1")
);
答案 0 :(得分:1)
您可以按顺序添加每个语句:
sql()
将SQL查询作为参数。它返回Operation
。 Operations.sequenceOf()
将Operation实例作为参数。
所以你可以做到
Operations.sequenceOf(
insertInto(...)
.columns(...)
.values(...)
.build(), // first operation of the sequence
sql("..."), // second operation of the sequence
sql("...")); // third operation of the sequence
或者你可以做到
Operations.sequenceOf(
insertInto(...)
.columns(...)
.values(...)
.build(), // first operation of the sequence
sql("...", // first SQL statement of the SQL operation
"...")); // second SQL statement of the SQL operation
也就是说,在插入语言后,您不必更新客户。相反,您应首先插入语言,然后插入客户,这将直接引用先前创建的语言。