如何使用wso2 ESB和MySQL确定插入或更新是否成功?

时间:2018-01-10 08:00:32

标签: mysql wso2esb

我使用wso2ESB 4.9。我希望在Mysql更新后知道有多少记录在更新。我使用下面的配置:

              <dbreport>
                <connection>
                  <pool>
                    <dsName>jdbc/localdb</dsName>
                  </pool>
                </connection>
                <statement>
                  <sql><![CDATA[update table1 set active=0  where username=?  ]]></sql>
                  <parameter expression="get-property('username')" type="VARCHAR"/>
                </statement>
              </dbreport>

如何知道有记录更新? 感谢

1 个答案:

答案 0 :(得分:0)

有两种方法。简单的就是使用dblookup并检索'row_count'; 另一种是创建存储过程或函数调用。一个例子是:

delimiter //
create function setActive (name VARCHAR(50)) returns int DETERMINISTIC
BEGIN
UPDATE table1 set active=0 where username=name;
RETURN ROW_COUNT();
END
//
delimiter ;

然后您可以在dblookup中使用:

  <sql>SELECT setActive(?)</sql>
  <parameter expression="get-property('username')" type="VARCHAR"/>
  <result name="res" column="row_count()"/>