如何使用xml在myBatis中调用函数?
我有这个功能
CREATE OR REPLACE FUNCTION save_audit_deletions(IN days numeric, IN
table_name text)
RETURNS void AS
$body$
DECLARE
interval INT;
BEGIN
UPDATE table_name SET backup = 1 WHERE backup = 0 AND creationdate >= now()::DATE - days AND creationdate < now()::DATE;
IF copy_func(table_name, days) > 0 THEN
DELETE FROM table_name WHERE backup = 1;
ELSE
UPDATE table_name SET backup = 0 WHERE backup = 1;
END IF;
END
$body$
LANGUAGE plpgsql;
如何调用此函数传递参数?谢谢。
答案 0 :(得分:1)
XML语句和Java映射器方法如下所示。
<update id="saveAuditDeletions" statementType="CALLABLE">
{call save_audit_deletions(#{days}, #{text})}
</update>
void saveAuditDeletions(@Param("days") Integer days, @Param("text") String text);
仅供参考,无需XML即可完成。
@Options(statementType = StatementType.CALLABLE)
@Update("{call save_audit_deletions(#{days}, #{text})}")
void saveAuditDeletions(@Param("days") Integer days, @Param("text") String text);